由于某些原因,我的雇主不想使用 pip 安装第三方软件包,并希望我使用仅托管在 trusty 上的软件包。因此,我现在无法在代码中使用 pytz。我将如何检查时区中的某个日期是否采用夏令时?这是我使用 pytz 的原始代码。
import pytz
import datetime
...
target_date = datetime.datetime.strptime(arg_date, "%Y-%m-%d")
time_zone = pytz.timezone('US/Eastern')
dst_date = time_zone.localize(target_date, is_dst=None)
est_hour = 24
if bool(dst_date.dst()) is True:
est_hour -= 4
else:
est_hour -= 5
Run Code Online (Sandbox Code Playgroud)