Skip to content

Commit

Permalink
Use timezone.utc without datetime module in path
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Oct 28, 2024
1 parent 9d29aae commit 673cc35
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions warcio/timeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def iso_date_to_datetime(string, tzinfo: timezone = None):
>>> iso_date_to_datetime('2013-12-26T10:11:12.000000Z')
datetime.datetime(2013, 12, 26, 10, 11, 12)
>>> iso_date_to_datetime('2013-12-26T10:11:12Z', tzinfo=datetime.timezone.utc)
>>> iso_date_to_datetime('2013-12-26T10:11:12Z', tzinfo=timezone.utc)
datetime.datetime(2013, 12, 26, 10, 11, 12, tzinfo=datetime.timezone.utc)
>>> iso_date_to_datetime('2013-12-26T10:11:12.000000Z', tzinfo=datetime.timezone.utc)
>>> iso_date_to_datetime('2013-12-26T10:11:12.000000Z', tzinfo=timezone.utc)
datetime.datetime(2013, 12, 26, 10, 11, 12, tzinfo=datetime.timezone.utc)
"""

Expand All @@ -72,7 +72,7 @@ def http_date_to_datetime(string, tzinfo: timezone = None):
>>> http_date_to_datetime('Thu, 26 Dec 2013 09:50:10 GMT')
datetime.datetime(2013, 12, 26, 9, 50, 10)
>>> http_date_to_datetime('Thu, 26 Dec 2013 09:50:10 GMT', tzinfo=datetime.timezone.utc)
>>> http_date_to_datetime('Thu, 26 Dec 2013 09:50:10 GMT', tzinfo=timezone.utc)
datetime.datetime(2013, 12, 26, 9, 50, 10, tzinfo=datetime.timezone.utc)
"""
return datetime(*parsedate(string)[:6], tzinfo=tzinfo)
Expand Down Expand Up @@ -295,15 +295,15 @@ def timestamp_to_datetime(string, tzinfo: timezone = None):
datetime.datetime(2010, 12, 31, 23, 59, 59)
# 14-digit with tzinfo
>>> timestamp_to_datetime('20141226095010', tzinfo=datetime.timezone.utc)
>>> timestamp_to_datetime('20141226095010', tzinfo=timezone.utc)
datetime.datetime(2014, 12, 26, 9, 50, 10, tzinfo=datetime.timezone.utc)
# 6-digit padding with tzinfo
>>> timestamp_to_datetime('201410', tzinfo=datetime.timezone.utc)
>>> timestamp_to_datetime('201410', tzinfo=timezone.utc)
datetime.datetime(2014, 10, 31, 23, 59, 59, tzinfo=datetime.timezone.utc)
# not a number! with tzinfo
>>> timestamp_to_datetime('2010abc', tzinfo=datetime.timezone.utc)
>>> timestamp_to_datetime('2010abc', tzinfo=timezone.utc)
datetime.datetime(2010, 12, 31, 23, 59, 59, tzinfo=datetime.timezone.utc)
"""
Expand Down

0 comments on commit 673cc35

Please sign in to comment.