Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: Fix datetime_to_timestamp #3208

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

vvoland
Copy link
Contributor

@vvoland vvoland commented Dec 22, 2023

Replace usage of deprecated function datetime.utcfromtimestamp and make sure the input date is UTC before subtracting.

Fixes warning:

 tests/integration/client_test.py::CancellableEventsTest::test_cancel_events
  /src/docker/utils/utils.py:398: 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).
    delta = dt - datetime.utcfromtimestamp(0)

Replace usage of deprecated function `datetime.utcfromtimestamp` and
make sure the input date is UTC before subtracting.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Copy link
Contributor

@Khushiyant Khushiyant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine solution for adding explicit timezone handling and epoch reference.
LGTM!

@thaJeztah
Copy link
Member

Thanks!

@glours @milas PTAL

@milas milas closed this Jan 3, 2024
@milas milas reopened this Jan 3, 2024
@milas
Copy link
Contributor

milas commented Jan 3, 2024

(ignore the close + re-open - was testing out updated repo perms 👼🏻)

Copy link
Contributor

@milas milas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah
Copy link
Member

Let me bring this one in; looks like CI is happy 🎉

@thaJeztah thaJeztah merged commit f467fd9 into docker:main Jan 3, 2024
19 checks passed
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.

4 participants