From cd412e22e571f0646a6bc3758af576442a613ae7 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Sat, 1 Oct 2016 14:02:22 +0100 Subject: [PATCH] Change add support for freebsd /var/db/zoneinfo when getting local timezone information. --- .gitignore | 3 ++- CHANGES.md | 1 + HACKS.txt | 1 + lib/tzlocal/unix.py | 7 +++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 59e5ad4..c104120 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,10 @@ restore/ ###################### # SB Test Related # +tests/cache/* tests/Logs/* tests/sickbeard.* -tests/cache.db +tests/*.db ###################### # Compiled source # diff --git a/CHANGES.md b/CHANGES.md index c0e2743..3b46999 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -190,6 +190,7 @@ * Fix add custom torrent RSS * Remove ILT torrent provider * Update Tornado Web Server 4.3.dev1 (1b6157d) to 4.4.dev1 (c2b4d05) +* Change add support for freebsd /var/db/zoneinfo when getting local timezone information ### 0.11.15 (2016-09-13 19:50:00 UTC) diff --git a/HACKS.txt b/HACKS.txt index 64667eb..0dbc4ee 100644 --- a/HACKS.txt +++ b/HACKS.txt @@ -10,3 +10,4 @@ Libs with customisations... /lib/requests/packages/urllib3/util/ssl_.py /lib/tornado /lib/tvdb/tvdb_api.py +/lib/tzlocal/unix.py diff --git a/lib/tzlocal/unix.py b/lib/tzlocal/unix.py index f1eff1e..9356ab0 100644 --- a/lib/tzlocal/unix.py +++ b/lib/tzlocal/unix.py @@ -90,6 +90,13 @@ def _get_localzone(_root='/'): # We found a timezone return pytz.timezone(etctz.replace(' ', '_')) + # look for FreeBSD's /var/db/zoneinfo file, which contains the zone name and a newline. + freebsd_zoneinfo = os.path.join(_root, 'var/db/zoneinfo') + if os.path.exists(freebsd_zoneinfo): + with open(freebsd_zoneinfo, 'rt') as tzfile: + data = tzfile.read().strip() + return pytz.timezone(data) + # systemd distributions use symlinks that include the zone name, # see manpage of localtime(5) and timedatectl(1) tzpath = os.path.join(_root, 'etc/localtime')