Skip to content

Conversation

ricardobranco777
Copy link

@ricardobranco777 ricardobranco777 commented Aug 20, 2025

Fix DeprecationWarning for datetime.datetime.utcfromtimestamp()

It suggests to use timezone-aware objects to represent datetimes in UTC with datetime.UTC but datetime.timezone.utc is backwards compatible.

Verification run: https://openqa.opensuse.org/tests/5261910#downloads

tests/unit/api_container_test.py::ContainerTest::test_log_since_with_datetime
  /src/tests/unit/api_container_test.py:1305: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    time = datetime.datetime.utcfromtimestamp(ts)

tests/unit/api_test.py::DockerApiTest::test_events_with_since_until
  /src/tests/unit/api_test.py:234: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    now = datetime.datetime.utcfromtimestamp(ts)

@ricardobranco777
Copy link
Author

ricardobranco777 commented Aug 23, 2025

Fixes deprecation warning noticed in #3335

Fix DeprecationWarning for datetime.datetime.utcfromtimestamp()

It suggests to use timezone-aware objects to represent datetimes in UTC
with datetime.UTC but datetime.timezone.utc is backwards compatible.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant