|
@@ -10,10 +10,13 @@ def to_localtime(ts):
|
|
return datetime(*time.localtime((ts - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds())[:6])
|
|
return datetime(*time.localtime((ts - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds())[:6])
|
|
|
|
|
|
|
|
|
|
-def parse_timestamp(timestamp):
|
|
|
|
|
|
+def parse_timestamp(timestamp, tzinfo=timezone.utc):
|
|
"""Parse a ISO 8601 timestamp string"""
|
|
"""Parse a ISO 8601 timestamp string"""
|
|
fmt = ISO_FORMAT if '.' in timestamp else ISO_FORMAT_NO_USECS
|
|
fmt = ISO_FORMAT if '.' in timestamp else ISO_FORMAT_NO_USECS
|
|
- return datetime.strptime(timestamp, fmt).replace(tzinfo=timezone.utc)
|
|
|
|
|
|
+ dt = datetime.strptime(timestamp, fmt)
|
|
|
|
+ if tzinfo is not None:
|
|
|
|
+ dt = dt.replace(tzinfo=tzinfo)
|
|
|
|
+ return dt
|
|
|
|
|
|
|
|
|
|
def timestamp(s):
|
|
def timestamp(s):
|