Skip to content

utils: Fix datetime_to_timestamp#3208

Merged
thaJeztah merged 1 commit into
docker:mainfrom
vvoland:fix-datetime_to_timestamp
Jan 3, 2024
Merged

utils: Fix datetime_to_timestamp#3208
thaJeztah merged 1 commit into
docker:mainfrom
vvoland:fix-datetime_to_timestamp

Conversation

@vvoland

@vvoland vvoland commented Dec 22, 2023

Copy link
Copy Markdown
Contributor

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>
@vvoland vvoland force-pushed the fix-datetime_to_timestamp branch from 5c5546c to 1784cc2 Compare December 22, 2023 10:31

@Khushiyant Khushiyant left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

Thanks!

@glours @milas PTAL

@milas milas closed this Jan 3, 2024
@milas milas reopened this Jan 3, 2024
@milas

milas commented Jan 3, 2024

Copy link
Copy Markdown
Contributor

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

@milas milas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@thaJeztah

Copy link
Copy Markdown
Member

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

@thaJeztah thaJeztah merged commit f467fd9 into docker:main Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants