我有些困惑,不太明白为什么会得到这样的结果。
我想尝试的是:
Take two timezones, one that uses DST and one that doesn't. ex: Romania (dst) and Venezuela(no dst).
For the timezone that has dst, create two datetimes. One in the interval of the dst, and one that isn't. Romania DST interval (4-10 / April-October). Ex:
from datetime import datetime from pytz import timezone tz1 = timezone('Europe/Bucharest') tz2 = timezone('America/Caracas') date1 = datetime(2016, 5, 5, 5, 0, 0, tzinfo=tz1) # its in the dst interval (5 o'clock, summer - dst) date1 = datetime(2016, 12, 5, 5, 0, 0, tzinfo=tz1) # isn't in the dst interval (5 o'clock, winter - no dst) x = date1.astimezone(tz2) y = date2.astimezone(tz2)
Shouldn't
x
andy
have different hours? Because date1 is in the DST interval, so 5 o'clock should mean a different hour than 5 o'clock in date2 when the datetime isn't in the DST interval.
然而,当转换为无夏令时时区时,x
和y
都具有相同的小时数。
感谢您提供的任何解释。