Don't break when system timezone is UTC

This commit is contained in:
MinchinWeb 2017-11-13 20:20:11 -07:00
parent 779a8f4ddf
commit 5dc724dd4d
2 changed files with 9 additions and 1 deletions

View file

@ -1,4 +1,6 @@
sudo: false
language: python language: python
cache: pip
python: python:
- "2.7" - "2.7"
- "3.3" - "3.3"

View file

@ -51,7 +51,13 @@ class DayOne(Journal.Journal):
except (KeyError, pytz.exceptions.UnknownTimeZoneError): except (KeyError, pytz.exceptions.UnknownTimeZoneError):
timezone = tzlocal.get_localzone() timezone = tzlocal.get_localzone()
date = dict_entry['Creation Date'] date = dict_entry['Creation Date']
date = date + timezone.utcoffset(date, is_dst=False) try:
date = date + timezone.utcoffset(date, is_dst=False)
except TypeError:
# if the system timezone is set to UTC,
# pytz.timezone.utcoffset() breaks when given the
# arg `is_dst`
pass
entry = Entry.Entry(self, date, text=dict_entry['Entry Text'], starred=dict_entry["Starred"]) entry = Entry.Entry(self, date, text=dict_entry['Entry Text'], starred=dict_entry["Starred"])
entry.uuid = dict_entry["UUID"] entry.uuid = dict_entry["UUID"]
entry._tags = [self.config['tagsymbols'][0] + tag.lower() for tag in dict_entry.get("Tags", [])] entry._tags = [self.config['tagsymbols'][0] + tag.lower() for tag in dict_entry.get("Tags", [])]