-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Exception when calling DateTime.astimezone #188
Comments
I've looked at the source more closely, and I've determined this is caused because DateTime does not implement I suggest an implementation similar to The following tests were used to test this solution. import pytz
import tomlkit
def test_datetime_astimezone():
# US/Pacific time zone
assert tomlkit.datetime("2022-12-25 12:23:34-05:00").astimezone(pytz.timezone("US/Pacific")).as_string() == "2022-12-25T09:23:34-08:00"
def test_datetime_astimezone_noargs():
# Use the local timezone
tomlkit.datetime("2022-12-25 12:23:34-05:00").astimezone()
def test_datetime_replace():
assert tomlkit.datetime("2022-12-25 12:23:34-05:00").replace(year=2021).as_string() == "2021-12-25T12:23:34-05:00" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: