-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtw-export-ical.py
More file actions
executable file
·32 lines (24 loc) · 846 Bytes
/
Copy pathtw-export-ical.py
File metadata and controls
executable file
·32 lines (24 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Author: Tomas Babej
## License: undetermined
import os
import datetime
import icalendar
import tasklib
tw = tasklib.TaskWarrior()
tasks = tw.tasks.filter('due.not:')
def export_to_ical(task):
calendar = icalendar.Calendar()
calendar.add('prodid', '-//Taskwarrior exporter//Version 1//EN')
calendar.add('version', '2.0')
event = icalendar.Event()
event['summary'] = task['description']
event.add('dtstart', task['due'])
event.add('dtend', task['due']+datetime.timedelta(seconds=1))
event.add('dtstamp', task['entry'])
event.add('uid', task['uuid'].upper())
calendar.add_component(event)
filename = '~/.calendars/tw/{0}.ics'.format(event['uid'])
with open(os.path.expanduser(filename), 'w') as f:
f.write(calendar.to_ical())
for task in tasks:
export_to_ical(task)