Skip to content

refactor: transition to UTC-aware datetimes #477

@shbatm

Description

@shbatm

Currently, pyisy.helpers.now() and ntp_to_system_time() return naive datetimes, often reflecting the local system clock. As part of modernizing the library to Python 3.11+ standards, we should transition these to return UTC-aware datetimes using datetime.UTC.

Considerations:

  • This is a breaking change for consumers that perform arithmetic with these values and expect naive objects.
  • It will shift last_changed, last_update, and last_edited values by the local UTC offset for consumers treating them as wall-clock time.
  • A CHANGELOG entry and potentially a major version bump (or a very clear migration path) will be required.

Proposed Change:

  • Update now() to use datetime.datetime.now(datetime.UTC).
  • Update ntp_to_system_time() to attach datetime.UTC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions