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

DateTime library uses deprecated datetime.utcnow() #4980

Closed
pekkaklarck opened this issue Dec 18, 2023 · 1 comment
Closed

DateTime library uses deprecated datetime.utcnow() #4980

pekkaklarck opened this issue Dec 18, 2023 · 1 comment

Comments

@pekkaklarck
Copy link
Member

pekkaklarck commented Dec 18, 2023

datetime.datetime.utcnow() has been deprecated in Python 3.12 and datetime.datetime.now(datetime.UTC) should be used instead. That datetime.UTC is new in Python 3.11, so we need to use either version or feature detection to avoid using it with earlier Python versions.

@pekkaklarck
Copy link
Member Author

pekkaklarck commented Dec 18, 2023

We cannot simply use datetime.datetime.now(datetime.UTC) because that returns a timezone aware datetime object that cannot be used together with non-timezone aware (i.e. naive) objects that we otherwise use with DateTime. Using datetime.datetime.now(datetime.UTC).replace(tzinfo=None) avoids that problem by removing timezone information and making the object naive.

DateTime also supporting aware objects and having better timezone support in general would be nice, but that requires quite a lot of changes. Can be considered later, but absolutely not in RF 7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant