From e5df236c8354ad8b0d6b68fea9517dd19616a5b7 Mon Sep 17 00:00:00 2001 From: Bart van Zon Date: Mon, 18 Aug 2014 22:03:03 +0200 Subject: [PATCH] fix incorrect timezone parsing --- rainbowstream/draw.py | 9 +++++---- setup.py | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 00d3e25..262fe4f 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -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) diff --git a/setup.py b/setup.py index e353257..eae5ce8 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ install_requires = [ "pyfiglet", "twitter", "Pillow", + "tzlocal", ] # Copy default config if not exists -- 2.25.1