Add explicit timezone when calculating isdst

This commit is contained in:
Jeff Epler 2021-12-15 22:46:07 -06:00
parent 807b24f897
commit 6e4107eac6
No known key found for this signature in database
GPG key ID: D5BF15AB975AB4DE

View file

@ -86,8 +86,8 @@ def isls(t: DateOrDatetime) -> bool:
def isdst(t: datetime.date, tz: datetime.tzinfo = Mountain) -> bool:
"""Return true if daylight saving time is active at the given moment"""
t = datetime.datetime(t.year, t.month, t.day)
"""Return true if daylight saving time is active at the start of the given UTC day"""
t = datetime.datetime(t.year, t.month, t.day, tzinfo=datetime.timezone.utc)
return bool(t.astimezone(tz).dst())