Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ra312/c3c83592de3e37b55b3b4cc40c1855f3 to your computer and use it in GitHub Desktop.
Save ra312/c3c83592de3e37b55b3b4cc40c1855f3 to your computer and use it in GitHub Desktop.
create_timezone_aware_datetime_objects
from datetime import datetime
str_datetime = "2022-04-11"
_until_time_created_unaware = datetime.strptime(str_datetime, "%Y-%M-%d") if str_datetime!= "" else datetime.now()
until_datetime_created_unaware = _until_time_created_unaware.replace(hour=23, minute=59, second=59)
until_datetime_created_aware = pytz.utc.localize(until_datetime_created_unaware)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment