Skip to content

Conversation

exploide
Copy link
Contributor

@exploide exploide commented Jul 4, 2024

datetime.utcfromtimestamp() is deprecated, timezone-aware datetime objects should be used instead.

This fixes a deprecation warning that appears in Python 3.12+.

datetime.utcfromtimestamp() is deprecated, timezone-aware datetime objects should be used instead
@cddmp
Copy link
Owner

cddmp commented Jul 17, 2024

Hi @exploide,
sorry for my late reply, there were lots of things going on during the last days!
Thank you for your continous support of this tool, I really appreciate that.
The PR looks good, just one question, since I haven't tested it so far:
Have you tested with which Python versions it might break?

@exploide
Copy link
Contributor Author

No problem, thanks for replying. :)

I haven't tested older versions but this is nothing I expect to break. datetime.fromtimestamp exists back to Python 2.7 and I found timezone.utc being mentioned in the docs of 3.5.

@exploide
Copy link
Contributor Author

Just tested the relevant portions of the code in a container. Even works down to Python 3.2:

Python 3.2.6 (default, Jan 18 2016, 19:21:14) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime, timezone
>>> tmp = 123456789
>>> dt = datetime.fromtimestamp(tmp, tz=timezone.utc)
>>> minutes = dt.minute
>>> hours = dt.hour
>>> time_diff = dt - datetime.fromtimestamp(0, tz=timezone.utc)
>>> print(time_diff.days)
1428

@cddmp
Copy link
Owner

cddmp commented Jul 18, 2024

Looks good!

@cddmp cddmp merged commit c6f42bb into cddmp:master Jul 18, 2024
@exploide exploide deleted the datetime branch July 18, 2024 17:18
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.

2 participants