Sfârșitul orei de vară

Lucrul cu date și ore în Python

Max Shron

Data Scientist and Author

Lucrul cu date și ore în Python

Lucrul cu date și ore în Python

Sfârșitul orei de vară

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)
Lucrul cu date și ore în Python

Sfârșitul orei de vară

(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
Lucrul cu date și ore în Python

Sfârșitul orei de vară

Lucrul cu date și ore în Python

Preparing Video For Download...