Ending Daylight Saving Time

Working with Dates and Times in Python

Max Shron

Data Scientist and Author

Working with Dates and Times in Python

Working with Dates and Times in Python

Ending Daylight Saving Time

eastern = tz.gettz('US/Eastern')
# 2017-11-05 01:00:00
first_1am = datetime(2017, 11, 5, 1, 0, 0, 
                     tzinfo = eastern)

tz.datetime_ambiguous(first_1am)
True
# 2017-11-05 01:00:00 again
second_1am = datetime(2017, 11, 5, 1, 0, 0, 
                      tzinfo = eastern)
second_1am = tz.enfold(second_1am)
Working with Dates and Times in Python

Ending Daylight Saving Time

(first_1am - second_1am).total_seconds()
0.0
first_1am = first_1am.astimezone(tz.UTC)
second_1am = second_1am.astimezone(tz.UTC)

(second_1am - first_1am).total_seconds()
3600.0
Working with Dates and Times in Python

Ending Daylight Saving Time

Working with Dates and Times in Python

Preparing Video For Download...