Created
July 7, 2022 06:55
-
-
Save ra312/c3c83592de3e37b55b3b4cc40c1855f3 to your computer and use it in GitHub Desktop.
create_timezone_aware_datetime_objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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