summaryrefslogtreecommitdiff
path: root/misc/tools/common.py
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2018-09-04 02:06:04 +0300
committerRasmus Andersson <rasmus@notion.se>2018-09-04 02:06:04 +0300
commit4ab36d3e3bec37edc7e0eb7f9e20b0d14d37071c (patch)
tree3a96301ecb0ec566de7cfa779504a64f24d54e3c /misc/tools/common.py
parent6785f6ea1cb049c2899ba8db602fe466c8b2e2a5 (diff)
downloadinter-4ab36d3e3bec37edc7e0eb7f9e20b0d14d37071c.tar.xz
update glyphinfo
Diffstat (limited to 'misc/tools/common.py')
-rw-r--r--misc/tools/common.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/misc/tools/common.py b/misc/tools/common.py
index c38ef817b..d53c8e755 100644
--- a/misc/tools/common.py
+++ b/misc/tools/common.py
@@ -3,6 +3,7 @@ from __future__ import print_function
import sys, os
from os.path import dirname, abspath, join as pjoin
import subprocess
+import time
# patch PYTHONPATH to include $BASEDIR/build/venv/python/site-packages
BASEDIR = abspath(pjoin(dirname(__file__), os.pardir, os.pardir))
@@ -34,5 +35,27 @@ def getVersion():
return _version
+_local_tz_offs = None
+def getLocalTimeZoneOffset(): # in seconds from UTC
+ # seriously ugly hack to get timezone offset in Python
+ global _local_tz_offs
+ if _local_tz_offs is None:
+ tzname = time.strftime("%Z", time.localtime())
+ s = time.strftime('%z', time.strptime(tzname, '%Z'))
+ i = 0
+ neg = False
+ if s[0] == '-':
+ neg = True
+ i = 1
+ elif s[0] == '+':
+ i = 1
+ h = int(s[i:i+2])
+ m = int(s[i+2:])
+ _local_tz_offs = ((h * 60) + m) * 60
+ if neg:
+ _local_tz_offs = -_local_tz_offs
+ return _local_tz_offs
+
+
# update environment to include $VENVDIR/bin
os.environ['PATH'] = os.path.join(VENVDIR, 'bin') + ':' + os.environ['PATH']