From ea19458e7ce18e5c98731c823b38cd252d4178a7 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sun, 8 Apr 2018 22:03:42 -0600 Subject: [PATCH] Work if timezone is UTC --- features/multiple_journals.feature | 2 +- jrnl/DayOneJournal.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/features/multiple_journals.feature b/features/multiple_journals.feature index 9c4f5992..18e801e2 100644 --- a/features/multiple_journals.feature +++ b/features/multiple_journals.feature @@ -43,4 +43,4 @@ Feature: Multiple journals Scenario: Gracefully handle a config without a default journal Given we use the config "multiple_without_default.yaml" When we run "jrnl fork this repo and fix something" - Then we should see the message "You have not specified a journal. Either provide a default journal in your config file, or specify one of your journals on the command line." + Then the output should contain "You have not specified a journal. Either provide a default journal in your config file, or specify one of your journals on the command line." diff --git a/jrnl/DayOneJournal.py b/jrnl/DayOneJournal.py index cc8ce2e9..54a1a83d 100644 --- a/jrnl/DayOneJournal.py +++ b/jrnl/DayOneJournal.py @@ -7,7 +7,7 @@ from . import Journal from . import time as jrnl_time import os import re -from datetime import datetime +from datetime import datetime, timedelta import time import fnmatch import plistlib @@ -49,7 +49,11 @@ class DayOne(Journal.Journal): except (KeyError, pytz.exceptions.UnknownTimeZoneError): timezone = tzlocal.get_localzone() date = dict_entry['Creation Date'] - date = date + timezone.utcoffset(date, is_dst=False) + if timezone != pytz.timezone('UTC'): + time_offset = timezone.utcoffset(date) + else: + time_offset = timedelta(0) + date = date + time_offset entry = Entry.Entry(self, date, text=dict_entry['Entry Text'], starred=dict_entry["Starred"]) entry.uuid = dict_entry["UUID"] entry._tags = [self.config['tagsymbols'][0] + tag.lower() for tag in dict_entry.get("Tags", [])]