Skip to content

python-aodntools: Incorrect use of datetime.utcnow() #125

Open

Description

@mhidas

Acceptance criteria

  1. 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.
  • From datetime docs:

the recommended way to create an object representing the current time in UTC is by calling datetime.now(timezone.utc)

Activity

  1. added
    bugSomething isn't working
    ncwriterRelated to creating netCDF files based on templates
    aggregated_timeseriesIssues relating to the aggregated time series product
    hourly_timeseriesIssues relating to the hourly time series product
    gridded_timeseriesIssues relating to the gridded time series product
    velocity_aggregatedIssues relating to the velocity aggregated time series product
    velocity_hourlyIssues relating to the velocity hourly time series product
    on Jun 17, 2020
  2. mhidas commented on Jun 14, 2022

    @mhidas
    ContributorAuthor

    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.

  3. removed
    aggregated_timeseriesIssues relating to the aggregated time series product
    hourly_timeseriesIssues relating to the hourly time series product
    gridded_timeseriesIssues relating to the gridded time series product
    velocity_aggregatedIssues relating to the velocity aggregated time series product
    velocity_hourlyIssues relating to the velocity hourly time series product
    on Jun 14, 2022
  4. changed the title [-]Incorrect use of datetime.utcnow() to set date_created attributes[/-] [+]python-aodntools: Incorrect use of datetime.utcnow()[/+] on Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingncwriterRelated to creating netCDF files based on templates

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions