Skip to content

Conversation

@schloerke
Copy link
Collaborator

The method "utcfromtimestamp" in class "datetime" is deprecated
Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.UTC) (reportDeprecated)

> The method "utcfromtimestamp" in class "datetime" is deprecated
>    Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.UTC) (reportDeprecated)
…datetime.utcnow()`

> The method "utcnow" in class "datetime" is deprecated
>    Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.UTC) (reportDeprecated)
@schloerke schloerke self-assigned this Feb 20, 2024
@schloerke schloerke marked this pull request as ready for review February 20, 2024 22:16
@schloerke
Copy link
Collaborator Author

Merging as lints are fixed

@schloerke schloerke merged commit 347c3dd into main Feb 20, 2024
@schloerke schloerke deleted the utc_update branch February 20, 2024 22:16
schloerke added a commit that referenced this pull request Feb 20, 2024
schloerke added a commit that referenced this pull request Feb 20, 2024
@wch
Copy link
Collaborator

wch commented Feb 20, 2024

I think the changelog should mention that this is a potentially breaking change, since the returned object is different, and the string formatting is different.

now = datetime.utcnow().timestamp()

y = datetime.utcfromtimestamp(now)
y
#> datetime.datetime(2024, 2, 21, 5, 37, 58, 761000)
print(y)
#> 2024-02-21 05:37:58.761000

x = datetime.fromtimestamp(now, timezone.utc)
x
#> datetime.datetime(2024, 2, 21, 5, 37, 58, 761000, tzinfo=datetime.timezone.utc)
print(x)
# 2024-02-21 05:37:58.761000+00:00

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.

3 participants