Skip to content

Commit

Permalink
Add UTC support for failing DayOne tests (#785)
Browse files Browse the repository at this point in the history
* [Dayone] don't break if the system timezone is UTC
* [DayOne] re-enable tests that were failing on Travis
* [DayOne] change as per code review to avoid `except: pass`
  • Loading branch information
MinchinWeb committed Apr 10, 2020
1 parent 8b7ebe2 commit 66027e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
13 changes: 1 addition & 12 deletions features/dayone.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Feature: Dayone specific implementation details.

# fails when system time is UTC (as on Travis-CI)
@skip
Scenario: Loading a DayOne Journal
Given we use the config "dayone.yaml"
When we run "jrnl -from 'feb 2013'"
Expand All @@ -15,15 +13,14 @@ Feature: Dayone specific implementation details.
2013-07-17 11:38 This entry is starred!
"""

# fails when system time is UTC (as on Travis-CI)
# broken still
@skip
Scenario: Entries without timezone information will be interpreted as in the current timezone
Given we use the config "dayone.yaml"
When we run "jrnl -until 'feb 2013'"
Then we should get no error
and the output should contain "2013-01-17T18:37Z" in the local time

@skip
Scenario: Writing into Dayone
Given we use the config "dayone.yaml"
When we run "jrnl 01 may 1979: Being born hurts."
Expand All @@ -33,8 +30,6 @@ Feature: Dayone specific implementation details.
1979-05-01 09:00 Being born hurts.
"""

# fails when system time is UTC (as on Travis-CI)
@skip
Scenario: Loading tags from a DayOne Journal
Given we use the config "dayone.yaml"
When we run "jrnl --tags"
Expand All @@ -44,8 +39,6 @@ Feature: Dayone specific implementation details.
@play : 1
"""

# fails when system time is UTC (as on Travis-CI)
@skip
Scenario: Saving tags from a DayOne Journal
Given we use the config "dayone.yaml"
When we run "jrnl A hard day at @work"
Expand All @@ -56,8 +49,6 @@ Feature: Dayone specific implementation details.
@play : 1
"""

# fails when system time is UTC (as on Travis-CI)
@skip
Scenario: Filtering by tags from a DayOne Journal
Given we use the config "dayone.yaml"
When we run "jrnl @work"
Expand All @@ -66,8 +57,6 @@ Feature: Dayone specific implementation details.
2013-05-17 11:39 This entry has tags!
"""

# fails when system time is UTC (as on Travis-CI)
@skip
Scenario: Exporting dayone to json
Given we use the config "dayone.yaml"
When we run "jrnl --export json"
Expand Down
6 changes: 5 additions & 1 deletion jrnl/DayOneJournal.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def open(self):
except (KeyError, pytz.exceptions.UnknownTimeZoneError):
timezone = tzlocal.get_localzone()
date = dict_entry["Creation Date"]
date = date + timezone.utcoffset(date, is_dst=False)
# convert the date to UTC rather than keep messing with
# timezones
if timezone.zone != "UTC":
date = date + timezone.utcoffset(date, is_dst=False)

entry = Entry.Entry(
self,
date,
Expand Down

0 comments on commit 66027e7

Please sign in to comment.