1
0
mirror of https://github.com/bspeice/metrik synced 2024-12-25 23:18:15 -05:00

Try to use local timezone if not parsed

This commit is contained in:
Bradlee Speice 2016-08-13 00:19:44 -04:00
parent 11f0e75fe6
commit 285172a14f

View File

@ -1,6 +1,7 @@
from __future__ import print_function
import csv
from dateutil.tz import tzlocal
import requests
from collections import namedtuple
from dateutil.parser import parse
@ -62,6 +63,8 @@ class LiborRateTask(MongoCreateTask):
# download with `requests`, I see both date (often incorrect) and time.
logging.info('Received string for publication time: {}'.format(row['publication']))
dt = parse(row['publication'])
if dt.tzinfo is None:
dt = tzlocal().localize(dt)
logging.info('Parsed datetime: {}'.format(dt))
logging.info('Parse timezone: {}'.format(dt.tzinfo))
dt = dt.replace(year=date.year, month=date.month, day=date.day)