From 900630dc5ad1ca7534accbff5492641042ed0a34 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Fri, 28 May 2021 20:36:04 +0700 Subject: [PATCH] Use dateutil instead of pytz to handle timezones --- hap_csv_upload.py | 8 ++++---- qhp-download-futures.py | 4 ++-- qhp-hap-transfer.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hap_csv_upload.py b/hap_csv_upload.py index b7ab136..b6a9fac 100644 --- a/hap_csv_upload.py +++ b/hap_csv_upload.py @@ -10,7 +10,7 @@ import datetime import struct import re -from pytz import timezone +import dateutil.tz def sec_from_period(period): if period == "M1": @@ -49,11 +49,11 @@ def main(): period = args.timeframe - utc_tz = timezone('UTC') + utc_tz = dateutil.tz.gettz('UTC') if args.timezone is None: tz = utc_tz else: - tz = timezone(args.timezone) + tz = dateutil.tz.gettz(args.timezone) out_symbol = args.hap_symbol @@ -95,7 +95,7 @@ def main(): minute = int(time[2:4]) second = int(time[4:6]) - dt = datetime.datetime(year, month, day, hour, minute, second, 0, utc_tz).astimezone(tz) - time_delta + dt = datetime.datetime(year, month, day, hour, minute, second, 0, tzinfo=tz) - time_delta dt = dt.astimezone(utc_tz) serialized_bars.write(struct.pack(" 0: data[ticker] = { 'bars' : bars } diff --git a/qhp-hap-transfer.py b/qhp-hap-transfer.py index 6ef12ef..2f405d8 100644 --- a/qhp-hap-transfer.py +++ b/qhp-hap-transfer.py @@ -9,7 +9,7 @@ import csv import datetime import struct import re -from pytz import timezone +import dateutil.tz def sec_from_period(period): if period == "M1": @@ -190,9 +190,9 @@ def main(): tickers = request_ticker_list(qhp) - tz = timezone('UTC') + tz = dateutil.tz.gettz('UTC') if args.timezone is not None: - tz = timezone(args.timezone) + tz = dateutil.tz.gettz(args.timezone) timedelta = datetime.timedelta(seconds=0) if args.time_delta is not None: