1
0
mirror of https://github.com/bspeice/metrik synced 2024-11-05 06:58:12 -05:00

Fix localization

This commit is contained in:
Bradlee Speice 2016-08-13 00:25:18 -04:00
parent 285172a14f
commit 79c51c16cc

View File

@ -1,6 +1,7 @@
from __future__ import print_function from __future__ import print_function
import csv import csv
import pytz
from dateutil.tz import tzlocal from dateutil.tz import tzlocal
import requests import requests
from collections import namedtuple from collections import namedtuple
@ -64,7 +65,9 @@ class LiborRateTask(MongoCreateTask):
logging.info('Received string for publication time: {}'.format(row['publication'])) logging.info('Received string for publication time: {}'.format(row['publication']))
dt = parse(row['publication']) dt = parse(row['publication'])
if dt.tzinfo is None: if dt.tzinfo is None:
dt = tzlocal().localize(dt) tzname = tzlocal().tzname
tz = pytz.timezone(tzname)
dt = tz.localize(dt)
logging.info('Parsed datetime: {}'.format(dt)) logging.info('Parsed datetime: {}'.format(dt))
logging.info('Parse timezone: {}'.format(dt.tzinfo)) logging.info('Parse timezone: {}'.format(dt.tzinfo))
dt = dt.replace(year=date.year, month=date.month, day=date.day) dt = dt.replace(year=date.year, month=date.month, day=date.day)