summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2016-04-20 13:29:42 +0200
committerTobias Brox <tobias@redpill-linpro.com>2016-04-20 13:29:42 +0200
commit36091f0336c8990671b07951351025227430c291 (patch)
tree09c45c825266cf0ffc1448a752c3c70050b72deb
parent38969f2c2eedb70ddcfb9a301c075641fdd48fe6 (diff)
parentda03408120de283e8fa87f126937ceb669a7f032 (diff)
downloadcalendar-cli-36091f0336c8990671b07951351025227430c291.zip
Merge pull request #27 from fgtham/whole-day
Whole day events
-rwxr-xr-xcalendar-cli.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/calendar-cli.py b/calendar-cli.py
index c34cdf7..4c349b8 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -237,9 +237,18 @@ def calendar_add(caldav_conn, args):
## TODO: error handling
event_duration_secs = int(event_duration[:-1]) * time_units[event_duration[-1:]]
dtstart = dateutil.parser.parse(event_spec[0])
- event.add('dtstart', dtstart)
- ## TODO: handle duration and end-time as options. default 3600s by now.
- event.add('dtend', dtstart + timedelta(0,event_duration_secs))
+ if args.whole_day:
+ if event_spec[1][-1:] != 'd':
+ raise ValueError('Duration of whole-day event must be multiple of 1d')
+ duration = int(event_spec[1][:-1])
+ dtstart = dateutil.parser.parse(event_spec[0])
+ dtend = dtstart + timedelta(days=duration)
+ event.add('dtstart', dtstart.date())
+ event.add('dtend', dtend.date())
+ else:
+ event.add('dtstart', dtstart)
+ ## TODO: handle duration and end-time as options. default 3600s by now.
+ event.add('dtend', dtstart + timedelta(0,event_duration_secs))
## TODO: what does the cryptic comment here really mean, and why was the dtstamp commented out? dtstamp is required according to the RFC.
## not really correct, and it breaks i.e. with google calendar
event.add('dtstamp', datetime.now())
@@ -652,6 +661,8 @@ def main():
calendar_add_parser.add_argument('event_time', help="Timestamp and duration of the event. See the documentation for event_time specifications")
calendar_add_parser.add_argument('summary', nargs='+')
calendar_add_parser.set_defaults(func=calendar_add)
+ calendar_add_parser.add_argument('--whole-day', help='Whole-day event', action='store_true', default=False)
+
calendar_addics_parser = calendar_subparsers.add_parser('addics')
calendar_addics_parser.add_argument('--file', help="ICS file to upload", default='-')
calendar_addics_parser.set_defaults(func=calendar_addics)