Show More
@@ -24,6 +24,7 b' from datetime import tzinfo, timedelta, datetime' | |||
|
24 | 24 | # constant for zero offset |
|
25 | 25 | ZERO = timedelta(0) |
|
26 | 26 | |
|
27 | ||
|
27 | 28 | class tzUTC(tzinfo): |
|
28 | 29 | """tzinfo object for UTC (zero offset)""" |
|
29 | 30 | |
@@ -39,10 +40,13 b' UTC = tzUTC() # type: ignore[abstract]' | |||
|
39 | 40 | |
|
40 | 41 | def utc_aware(unaware): |
|
41 | 42 | """decorator for adding UTC tzinfo to datetime's utcfoo methods""" |
|
43 | ||
|
42 | 44 | def utc_method(*args, **kwargs): |
|
43 | 45 | dt = unaware(*args, **kwargs) |
|
44 | 46 | return dt.replace(tzinfo=UTC) |
|
47 | ||
|
45 | 48 | return utc_method |
|
46 | 49 | |
|
50 | ||
|
47 | 51 | utcfromtimestamp = utc_aware(datetime.utcfromtimestamp) |
|
48 | 52 | utcnow = utc_aware(datetime.utcnow) |
General Comments 0
You need to be logged in to leave comments.
Login now