You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
python-aodntools: Incorrect use of datetime.utcnow() #125
All uses of datetime.utcnow() have been replaced with datetime.now(timezone.utc)
Notes
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
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.
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.
changed the title [-]Incorrect use of datetime.utcnow() to set date_created attributes[/-][+]python-aodntools: Incorrect use of datetime.utcnow()[/+]on Mar 31, 2025
Activity
get current UTC timestamps in the recommended way
mhidas commentedon Jun 14, 2022
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.
[-]Incorrect use of datetime.utcnow() to set date_created attributes[/-][+]python-aodntools: Incorrect use of datetime.utcnow()[/+]