From 285172a14f20408bffe846ea105e7334adf0247f Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sat, 13 Aug 2016 00:19:44 -0400 Subject: [PATCH] Try to use local timezone if not parsed --- metrik/tasks/ice.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metrik/tasks/ice.py b/metrik/tasks/ice.py index ab0fdb8..176120f 100644 --- a/metrik/tasks/ice.py +++ b/metrik/tasks/ice.py @@ -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)