diff options
| author | 2020-04-14 18:18:40 -0400 | |
|---|---|---|
| committer | 2020-04-14 18:18:40 -0400 | |
| commit | cf188f30e1c27bdb900fa2623a9ff91b944633b2 (patch) | |
| tree | 94803cd79aa8aaefd09d9bbc7b9c8029b415c885 /gallery_dl/text.py | |
| parent | e4887ae6b00c50fbbde531cc274c77b076bd821d (diff) | |
New upstream version 1.13.4upstream/1.13.4
Diffstat (limited to 'gallery_dl/text.py')
| -rw-r--r-- | gallery_dl/text.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gallery_dl/text.py b/gallery_dl/text.py index a3f4e0a..3bb6390 100644 --- a/gallery_dl/text.py +++ b/gallery_dl/text.py @@ -233,7 +233,7 @@ def parse_timestamp(ts, default=None): return default -def parse_datetime(date_string, format="%Y-%m-%dT%H:%M:%S%z"): +def parse_datetime(date_string, format="%Y-%m-%dT%H:%M:%S%z", utcoffset=0): """Create a datetime object by parsing 'date_string'""" try: if format.endswith("%z") and date_string[-3] == ":": @@ -244,7 +244,11 @@ def parse_datetime(date_string, format="%Y-%m-%dT%H:%M:%S%z"): d = datetime.datetime.strptime(ds, format) o = d.utcoffset() if o is not None: - d = d.replace(tzinfo=None) - o # convert to naive UTC + # convert to naive UTC + d = d.replace(tzinfo=None) - o + elif utcoffset: + # apply manual UTC offset + d += datetime.timedelta(0, utcoffset * -3600) return d except (TypeError, IndexError, KeyError): return None |
