fix incorrect timezone parsing
authorBart van Zon <bartvanzon@gmail.com>
Mon, 18 Aug 2014 20:03:03 +0000 (22:03 +0200)
committerBart van Zon <bartvanzon@gmail.com>
Mon, 18 Aug 2014 20:03:07 +0000 (22:03 +0200)
rainbowstream/draw.py
setup.py

index 00d3e252ec0766bdae4b03383ea07f8c554ab93c..262fe4f492c39f51386ef2e2652c5bd1e494e40a 100644 (file)
@@ -9,6 +9,7 @@ from twitter.util import printNicely
 from functools import wraps
 from pyfiglet import figlet_format
 from dateutil import parser
+from tzlocal import get_localzone
 from .c_image import *
 from .colors import *
 from .config import *
@@ -168,7 +169,7 @@ def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]):
     retweet_count = t['retweet_count']
     favorite_count = t['favorite_count']
     date = parser.parse(created_at)
-    date = date - datetime.timedelta(seconds=time.timezone)
+    date = date.astimezone(get_localzone())
     clock_format = '%Y/%m/%d %H:%M:%S'
     try:
         clock_format = c['FORMAT']['TWEET']['CLOCK_FORMAT']
@@ -334,7 +335,7 @@ def print_message(m, check_semaphore=False):
     recipient_name = m['recipient']['name']
     mid = m['id']
     date = parser.parse(m['created_at'])
-    date = date - datetime.timedelta(seconds=time.timezone)
+    date = date.astimezone(get_localzone())
     clock_format = '%Y/%m/%d %H:%M:%S'
     try:
         clock_format = c['FORMAT']['MESSAGE']['CLOCK_FORMAT']
@@ -427,7 +428,7 @@ def show_profile(u):
     location = 'Location : ' + color_func(c['PROFILE']['location'])(location)
     url = 'URL : ' + (color_func(c['PROFILE']['url'])(url) if url else '')
     date = parser.parse(created_at)
-    date = date - datetime.timedelta(seconds=time.timezone)
+    date = date.astimezone(get_localzone())
     clock = date.strftime('%Y/%m/%d %H:%M:%S')
     clock = 'Join at ' + color_func(c['PROFILE']['clock'])(clock)
 
@@ -506,7 +507,7 @@ def print_list(group):
         mode = color_func(c['GROUP']['mode'])('Type: ' + mode)
         created_at = grp['created_at']
         date = parser.parse(created_at)
-        date = date - datetime.timedelta(seconds=time.timezone)
+        date = date.astimezone(get_localzone())
         clock = date.strftime('%Y/%m/%d %H:%M:%S')
         clock = 'Created at ' + color_func(c['GROUP']['clock'])(clock)
 
index e3532579bb86e416db9852ff9be941c7ee7f32ed..eae5ce82da4134d05c2545e6a2d0b73ff171d49e 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -12,6 +12,7 @@ install_requires = [
     "pyfiglet",
     "twitter",
     "Pillow",
+    "tzlocal",
 ]
 
 # Copy default config if not exists