We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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.datetime.utcnow()
strptime
See discussion in #3705 (comment), datetime.datetime.utcnow() is marked as deprecated and might be removed after Python 3.12.
The same issue has been reported to monty as well: materialsvirtuallab/monty#275.
monty
But the new replacement returns slightly different output (an additional +00:00 at the end), which breaks strptime:
+00:00
import datetime start_time_old = datetime.datetime.utcnow() # 2024-03-25 08:46:23.748342 start_time_new = datetime.datetime.now(datetime.UTC) # 2024-03-25 08:46:23.748472+00:00 print(start_time_old, start_time_new) dt_old = datetime.datetime.strptime( str(start_time_old), "%Y-%m-%d %H:%M:%S.%f" ) print(dt_old) dt_new = datetime.datetime.strptime( str(start_time_new), "%Y-%m-%d %H:%M:%S.%f" ) print(dt_new)
Raises:
Traceback (most recent call last): File "/Users/yang/developer/test/test.py", line 16, in <module> dt = datetime.datetime.strptime( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/_strptime.py", line 554, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/_strptime.py", line 336, in _strptime raise ValueError("unconverted data remains: %s" % ValueError: unconverted data remains: +00:00
The text was updated successfully, but these errors were encountered:
No branches or pull requests
datetime.datetime.utcnow()
deprecatedSee discussion in #3705 (comment),
datetime.datetime.utcnow()
is marked as deprecated and might be removed after Python 3.12.The same issue has been reported to
monty
as well: materialsvirtuallab/monty#275.But the new replacement returns slightly different output (an additional
+00:00
at the end), which breaksstrptime
:Raises:
The text was updated successfully, but these errors were encountered: