glamod / glamod-ingest

Database preparation and ingestion for GLAMOD
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

Fix datetime issue with timezone pre-1800 #55

Closed agstephens closed 3 years ago

agstephens commented 3 years ago

Use of <datetime>.astimezone(datetime.timezone.utc) was failing for dates before 1800 and returning error:

offset must be a timedelta representing a whole number of minutes, not datetime.timedelta(-1, 86325).

Seemed to only affect python3.6 datetime.

Tried installing newer version but did not work.

Resolved by removing use of astimezone() and instead, just add +00:00 to the end of the start time and end time before SELECTing in SQL query.

Fixed in commit: https://github.com/glamod/cdm-lens/commit/bcd157e0a0398479f99ceba5d81aa78ac98c1ad0#diff-e310963ed59f56a73514e9eebdcd9b056bbf047a07b13623b2f78b00754d7b2e