remove pytz

main
samerbam 1 year ago
parent 8199fe4432
commit 0bb4cdcdd6

@ -18,31 +18,31 @@ data = TodoDatabase()
from datetime import datetime, time, timedelta
import pytz
# import pytz
from zoneinfo import ZoneInfo
from datetime import timezone
def midnight_UTC(offset):
# def midnight_UTC(offset):
# Construct a timezone object
tz = pytz.timezone('America/Toronto')
# # Construct a timezone object
# tz = pytz.timezone('America/Toronto')
# Work out today/now as a timezone-aware datetime
today = datetime.now(tz)
# # Work out today/now as a timezone-aware datetime
# today = datetime.now(tz)
# 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}
# variable is timezone aware
target_day = today + timedelta(days=1) * offset
# # 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}
# # variable is timezone aware
# target_day = today + timedelta(days=1) * offset
# Discard hours, minutes, seconds and microseconds
midnight_aware = tz.localize(
datetime.combine(target_day, time(0, 0, 0, 0)), is_dst=None)
# # Discard hours, minutes, seconds and microseconds
# midnight_aware = tz.localize(
# datetime.combine(target_day, time(0, 0, 0, 0)), is_dst=None)
# Convert to UTC
midnight_UTC = midnight_aware.astimezone(pytz.utc)
# # Convert to UTC
# midnight_UTC = midnight_aware.astimezone(pytz.utc)
return midnight_UTC
# return midnight_UTC

Loading…
Cancel
Save