Created
October 23, 2012 12:37
-
-
Save domenkozar/3938518 to your computer and use it in GitHub Desktop.
Timezone test
This file contains 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 datetime | |
import icalendar | |
import pytz | |
tz = pytz.timezone('Europe/Ljubljana') | |
dt = datetime.datetime(2012, 10, 23, 14, 0, 0) | |
print "datetime without timezone information: ", dt | |
dt_localized = tz.localize(dt) | |
print "localized into DST Europe/Ljubljana: ", dt_localized | |
print "Europe/Ljubljana to UTC time: ", dt_localized.astimezone(pytz.utc) | |
event = icalendar.Event() | |
event.add('dtstart', dt_localized) | |
print "icalendat vevent dtstart with localized to Europe/Ljubljana: ", event.to_ical() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
datetime without timezone information: 2012-10-23 14:00:00
localized into DST Europe/Ljubljana: 2012-10-23 14:00:00+02:00
Europe/Ljubljana to UTC time: 2012-10-23 12:00:00+00:00
icalendat vevent dtstart with localized to Europe/Ljubljana: BEGIN:VEVENT
DTSTART;TZID=Europe/Ljubljana;VALUE=DATE-TIME:20121023T140000
END:VEVENT