aodn / python-aodntools

Repository for templates and code relating to generating standard NetCDF files for the Australia Ocean Data Network
GNU Lesser General Public License v3.0
10 stars 3 forks source link

Incorrect use of datetime.utcnow() to set date_created attributes #125

Open mhidas opened 4 years ago

mhidas commented 4 years ago

This function can potentially return the system's local time as if it was UTC (see warning in datetime docs, or in more detail in this blog). This will lead to at most an 11-hour offset, which is not a huge problem, but it would be easy to fix.

datetime.utcnow() is currently used to set the creation date (global attribute and in file names) in all timeseries_products code, and in ncwriter/imos_template.py

mhidas commented 2 years ago

This has been fixed for timeseries_products. For ncwriter there was also an update required in the unittests, and an additional issue with Python 3.5 - so I've left this for later.