remove pytz

This commit is contained in:
samerbam 2023-08-27 00:35:13 -04:00
parent 8199fe4432
commit 0bb4cdcdd6

View File

@ -18,31 +18,31 @@ data = TodoDatabase()
from datetime import datetime, time, timedelta from datetime import datetime, time, timedelta
import pytz # import pytz
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
from datetime import timezone from datetime import timezone
def midnight_UTC(offset): # def midnight_UTC(offset):
# Construct a timezone object # # Construct a timezone object
tz = pytz.timezone('America/Toronto') # tz = pytz.timezone('America/Toronto')
# Work out today/now as a timezone-aware datetime # # Work out today/now as a timezone-aware datetime
today = datetime.now(tz) # today = datetime.now(tz)
# Adjust by the offset. Note that that adding 1 day might actually move us 23 or 25 # # Adjust by the offset. Note that that adding 1 day might actually move us 23 or 25
# hours into the future, depending on daylight savings. This works because the {today} # # hours into the future, depending on daylight savings. This works because the {today}
# variable is timezone aware # # variable is timezone aware
target_day = today + timedelta(days=1) * offset # target_day = today + timedelta(days=1) * offset
# Discard hours, minutes, seconds and microseconds # # Discard hours, minutes, seconds and microseconds
midnight_aware = tz.localize( # midnight_aware = tz.localize(
datetime.combine(target_day, time(0, 0, 0, 0)), is_dst=None) # datetime.combine(target_day, time(0, 0, 0, 0)), is_dst=None)
# Convert to UTC # # Convert to UTC
midnight_UTC = midnight_aware.astimezone(pytz.utc) # midnight_UTC = midnight_aware.astimezone(pytz.utc)
return midnight_UTC # return midnight_UTC