You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've looked at the source more closely, and I've determined this is caused because DateTime does not implement replace and astimezone. I believe this is an issue for the same reason add and sub need to be implemented.
I suggest an implementation similar to __add__ and __sub__ for astimezone and replace. replace() should also be implemented in Time and Date.
The following tests were used to test this solution.
importpytzimporttomlkitdeftest_datetime_astimezone():
# US/Pacific time zoneasserttomlkit.datetime("2022-12-25 12:23:34-05:00").astimezone(pytz.timezone("US/Pacific")).as_string() =="2022-12-25T09:23:34-08:00"deftest_datetime_astimezone_noargs():
# Use the local timezonetomlkit.datetime("2022-12-25 12:23:34-05:00").astimezone()
deftest_datetime_replace():
asserttomlkit.datetime("2022-12-25 12:23:34-05:00").replace(year=2021).as_string() =="2021-12-25T12:23:34-05:00"
When attempting to use
tomlkit.items.DateTime.astimezone()
, aTypeError
is raised.The current workaround is to reinitialize the object using the datetime module.
The text was updated successfully, but these errors were encountered: