Skip to content

Replace deprecated datetime.utcnow() in Elexon plotting and tests #403

@SaitejaKommi

Description

@SaitejaKommi

Description

The Elexon plotting flow and its tests currently use datetime.utcnow(), which is deprecated in Python 3.12+ and emits deprecation warnings.

We should migrate to timezone-aware UTC datetimes (e.g., datetime.now(datetime.UTC)) while preserving the existing behavior for start/end datetime calculations.

This will reduce warning noise and ensure the code remains future-compatible with newer Python versions.

Scope

  • elexon_plots.py
  • test_elexon_plot.py

Expected Behavior

  • No datetime.utcnow() deprecation warnings from these code paths.
  • Datetime handling remains functionally equivalent.

Acceptance Criteria

  • All datetime.utcnow() usage replaced with timezone-aware alternatives.
  • No deprecation warnings from these files.
  • Existing Elexon tests continue to pass.
  • Changes limited to Elexon code and tests only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions