- commit
- 304791a5dbc7f59d9ca77d5f6022069b254fa02f
- parent
- 62ac7850ea057b5609e2e13f84f97d478893e59a
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-10-31 15:37
add feature: by-day
Diffstat
| M | cal.py | 18 | ++++++++++++++---- |
1 files changed, 14 insertions, 4 deletions
diff --git a/cal.py b/cal.py
@@ -235,6 +235,8 @@ def _parse_args(argv=None): 235 235 parser.add_argument('-t', nargs='?', dest='today', metavar='[[yyyy.mm.dd', 236 236 help='Act like the specified value is "today" instead of using the ' 237 237 'current date.') -1 238 parser.add_argument('--by-day', '-b', action='store_true', -1 239 help='Print a single line for each day') 238 240 return parser.parse_args(argv) 239 241 240 242 @@ -264,10 +266,18 @@ def main(): 264 266 265 267 date = args.d_start 266 268 while date <= args.d_end:267 -1 for tpl, desc in entries:268 -1 if is_match(tpl, date):269 -1 star = '' if 'year' in tpl else '*'270 -1 print(date.strftime('%a %b %d') + star + '\t' + desc)-1 269 ds = date.strftime('%a %b %d') -1 270 if args.by_day: -1 271 events = [] -1 272 for tpl, desc in entries: -1 273 if is_match(tpl, date): -1 274 events.append(desc) -1 275 print(ds + '\t' + '; '.join(events)) -1 276 else: -1 277 for tpl, desc in entries: -1 278 if is_match(tpl, date): -1 279 star = '' if 'year' in tpl else '*' -1 280 print(ds + star + '\t' + desc) 271 281 date = date + datetime.timedelta(1) 272 282 273 283