mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Workaround for get_localzone on OS X
This commit is contained in:
parent
ed20660815
commit
6fbd4e7d7e
2 changed files with 14 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
try: from . import Entry
|
||||
except (SystemError, ValueError): import Entry
|
||||
from util import get_local_timezone
|
||||
import codecs
|
||||
import os
|
||||
try: import parsedatetime.parsedatetime_consts as pdt
|
||||
|
@ -10,8 +11,6 @@ except ImportError: import parsedatetime.parsedatetime as pdt
|
|||
import re
|
||||
from datetime import datetime
|
||||
import time
|
||||
import pytz
|
||||
from tzlocal import get_localzone
|
||||
try: import simplejson as json
|
||||
except ImportError: import json
|
||||
import sys
|
||||
|
@ -32,6 +31,7 @@ try:
|
|||
except ImportError:
|
||||
colorama = None
|
||||
import plistlib
|
||||
import pytz
|
||||
import uuid
|
||||
|
||||
|
||||
|
@ -329,7 +329,6 @@ class DayOne(Journal):
|
|||
# that have a uuid will be old ones, and only the one that doesn't will
|
||||
# have a new one!
|
||||
if not hasattr(entry, "uuid"):
|
||||
timezone = str(get_localzone())
|
||||
utc_time = datetime.utcfromtimestamp(time.mktime(entry.date.timetuple()))
|
||||
new_uuid = uuid.uuid1().hex
|
||||
filename = os.path.join(self.config['journal'], "entries", new_uuid+".doentry")
|
||||
|
@ -337,7 +336,7 @@ class DayOne(Journal):
|
|||
'Creation Date': utc_time,
|
||||
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
||||
'Entry Text': entry.title+"\n"+entry.body,
|
||||
'Time Zone': timezone,
|
||||
'Time Zone': get_local_timezone(),
|
||||
'UUID': new_uuid
|
||||
}
|
||||
plistlib.writePlist(entry_plist, filename)
|
||||
|
|
11
jrnl/util.py
11
jrnl/util.py
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
import sys
|
||||
import os
|
||||
from tzlocal import get_localzone
|
||||
|
||||
def py23_input(msg):
|
||||
if sys.version_info[0] == 3:
|
||||
|
@ -8,3 +10,12 @@ def py23_input(msg):
|
|||
except SyntaxError: return ""
|
||||
else:
|
||||
return raw_input(msg)
|
||||
|
||||
def get_local_timezone():
|
||||
"""Returns the Olson identifier of the local timezone.
|
||||
In a happy world, tzlocal.get_localzone would do this, but there's a bug on OS X
|
||||
that prevents that right now: https://github.com/regebro/tzlocal/issues/6"""
|
||||
if "darwin" in sys.platform:
|
||||
return os.popen("systemsetup -gettimezone").read().replace("Time Zone: ", "").strip()
|
||||
else:
|
||||
return str(get_localzone())
|
||||
|
|
Loading…
Add table
Reference in a new issue