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

pytz.exceptions.AmbiguousTimeError raised with certain date times formats #1577

Open
fredkingham opened this issue Jul 31, 2018 · 2 comments

Comments

@fredkingham
Copy link
Contributor

 from opal.core import serialization
 serialization.deserialize_datetime("29/10/2017 01:00:00")

raises AmbiguousTimeError: 2017-10-29 01:00:00

Solutions are
a) include tz in the datetime input format
b) change the timezone.make_aware call to timezone.make_aware(a, timezone.get_current_timezone(), is_dst=False)

I think we should go with b for the time being.

@davidmiller
Copy link
Member

Can we have a better reproduction case?

>>> from opal.core import serialization
>>> serialization.deserialize_datetime("29/10/2017 01:00:00")
datetime.datetime(2017, 10, 29, 1, 0, tzinfo=<UTC>)

@davidmiller
Copy link
Member

    def test_deserialize_ambiguous_datetime(self):
        expected = timezone.make_aware(datetime.datetime(2017, 10, 29, 1,0,0))
        value = "29/10/2017 01:00:00"
        self.assertEqual(expected, serialization.deserialize_datetime(value))

(This unittest passes)

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

No branches or pull requests

2 participants