1
0
mirror of https://github.com/bspeice/metrik synced 2024-11-23 15:48:10 -05:00

Just set timezone to America/New_York

This commit is contained in:
Bradlee Speice 2016-08-13 02:19:11 -04:00
parent f1d2ec524c
commit e6db9f2551
3 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,7 @@
from __future__ import print_function from __future__ import print_function
import csv import csv
import pytz
import requests import requests
from collections import namedtuple from collections import namedtuple
from dateutil.parser import parse from dateutil.parser import parse
@ -62,6 +63,13 @@ class LiborRateTask(MongoCreateTask):
# download with `requests`, I see both date (often incorrect) and time. # download with `requests`, I see both date (often incorrect) and time.
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:
# Seems like the messed up timezone is always America/New_York
# I'd be interested to know if it's an IP based thing, but the
# Travis settings resolve the `local` timezone to UTC so just
# manually set New York here to work around that.
tz = pytz.timezone('America/New_York')
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)

View File

@ -4,4 +4,3 @@ pyquery>=1.2.9
requests>=2.9.1 requests>=2.9.1
pandas>=0.17.1 pandas>=0.17.1
pymongo>=3.2 pymongo>=3.2
dateutil>=2.4.2

View File

@ -14,7 +14,6 @@ setup(
'six >= 1.10.0', 'six >= 1.10.0',
'pymongo >= 3.2', 'pymongo >= 3.2',
'pytz >= 2016.6.1', 'pytz >= 2016.6.1',
'dateutil >= 2.4.2'
], ],
setup_requires=[ setup_requires=[
'pytest_runner' 'pytest_runner'