From 830cfb37d1435f2a86ff1744f7bd1530d81e5ced Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 16 Sep 2013 10:45:57 -0700 Subject: [PATCH 1/3] Fixes #93 --- jrnl/util.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jrnl/util.py b/jrnl/util.py index 28499933..4fc2575b 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -4,6 +4,7 @@ import sys import os from tzlocal import get_localzone import getpass as gp +import pytz PY3 = sys.version_info[0] == 3 PY2 = sys.version_info[0] == 2 @@ -41,6 +42,13 @@ def get_local_timezone(): global __cached_tz if not __cached_tz and "darwin" in sys.platform: __cached_tz = os.popen("systemsetup -gettimezone").read().replace("Time Zone: ", "").strip() - elif not __cached_tz: + if not __cached_tz or __cached_tz not in pytz.all_timezones_set: + link = os.readlink("/etc/localtime") + # This is something like /usr/share/zoneinfo/America/Los_Angeles. + # Find second / from right and take the substring + __cached_tz = link[link.rfind('/', 0, link.rfind('/'))+1:] + if not __cached_tz or __cached_tz not in pytz.all_timezones_set: __cached_tz = str(get_localzone()) + if not __cached_tz or __cached_tz not in pytz.all_timezones_set: + __cached_tz = "UTC" return __cached_tz From 79ce87014c0c22e645fd9d181b71ebc081da2a72 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 16 Sep 2013 10:46:02 -0700 Subject: [PATCH 2/3] Version bump --- CHANGELOG.md | 4 ++++ jrnl/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20fac307..4aa0be7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Changelog #### 1.5.5 +* [Fixed] Fixed a bug where on OS X, the timezone could only be accessed on administrator accounts. + +#### 1.5.5 + * [Fixed] Detects DayOne journals stored in `~/Library/Mobile Data` as well. #### 1.5.4 diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 28fe63cd..abed3311 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line. """ __title__ = 'jrnl' -__version__ = '1.5.5' +__version__ = '1.5.6' __author__ = 'Manuel Ebert' __license__ = 'MIT License' __copyright__ = 'Copyright 2013 Manuel Ebert' From bac1dcd6058bb5931ba9e032215eabb990ae810c Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 16 Sep 2013 10:57:37 -0700 Subject: [PATCH 3/3] Treat non-OS X separately --- jrnl/util.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jrnl/util.py b/jrnl/util.py index 4fc2575b..4f6031d5 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -42,12 +42,12 @@ def get_local_timezone(): global __cached_tz if not __cached_tz and "darwin" in sys.platform: __cached_tz = os.popen("systemsetup -gettimezone").read().replace("Time Zone: ", "").strip() - if not __cached_tz or __cached_tz not in pytz.all_timezones_set: - link = os.readlink("/etc/localtime") - # This is something like /usr/share/zoneinfo/America/Los_Angeles. - # Find second / from right and take the substring - __cached_tz = link[link.rfind('/', 0, link.rfind('/'))+1:] - if not __cached_tz or __cached_tz not in pytz.all_timezones_set: + if not __cached_tz or __cached_tz not in pytz.all_timezones_set: + link = os.readlink("/etc/localtime") + # This is something like /usr/share/zoneinfo/America/Los_Angeles. + # Find second / from right and take the substring + __cached_tz = link[link.rfind('/', 0, link.rfind('/'))+1:] + elif not __cached_tz: __cached_tz = str(get_localzone()) if not __cached_tz or __cached_tz not in pytz.all_timezones_set: __cached_tz = "UTC"