Created
April 19, 2016 17:25
-
-
Save tommorris/179a62d65a50cc893fb03fb6ed618b26 to your computer and use it in GitHub Desktop.
How python iCalendar, iso8601 and pytz can work together for ICS implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import icalendar | |
import pytz | |
ev = icalendar.Event() | |
ev.add('dtstart', iso8601.parse_date("2016-01-01 00:00:00", default_timezone=pytz.timezone("Asia/Tokyo"))) | |
print(ev.to_ical()) | |
# BEGIN:VEVENT | |
# DTSTART;TZID=Asia/Tokyo;VALUE=DATE-TIME:20160101T000000 | |
# END:VEVENT | |
ev = icalendar.Event() | |
ev.add('dtstart', iso8601.parse_date("2016-01-01 00:00:00+09:00", default_timezone=None)) | |
print ev.to_ical() | |
# BEGIN:VEVENT | |
# DTSTART;TZID="+09:00";VALUE=DATE-TIME:20160101T000000 | |
# END:VEVENT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment