mirror of
				https://github.com/bspeice/metrik
				synced 2025-10-30 08:50:54 -04:00 
			
		
		
		
	Try to use local timezone if not parsed
This commit is contained in:
		| @ -1,6 +1,7 @@ | |||||||
| from __future__ import print_function | from __future__ import print_function | ||||||
|  |  | ||||||
| import csv | import csv | ||||||
|  | from dateutil.tz import tzlocal | ||||||
| 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,8 @@ 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: | ||||||
|  |                     dt = tzlocal().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) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Bradlee Speice
					Bradlee Speice