Module providing a timezone aware
datetime.datetime compatible object.Supports CPython 2.6 - 3.5 and PyPy.
- Drop-in replacement for
datetime.datetime - Simple implementation that leverages the built-in
datetimemodule as much as possible - Excellent test coverage
datetime.datetime objects aren't aware by default.New projects should always use timezone aware
datetime.datetime objects, but the Python standard library doesn't make that easy.
AwareDatetime is here to help!You may also have existing code that needs to become timezone aware and migrating code to become timezone aware is tricky.
Using
AwareDatetime will help you track what code has been migrated to support timezone.A drop-in replacement for datetime.datetime that always provide timezone aware objects.
>>> from awaredatetime import AwareDatetime
>>> AwareDatetime(2016, 1, 1)
AwareDatetime(2016, 1, 1, 0, 0, tzinfo=<UTC>)
>>> import datetime
>>> AwareDatetime.from_datetime(datetime.datetime(2016, 1, 1))
AwareDatetime(2016, 1, 1, 0, 0, tzinfo=<UTC>)
>>>Not implemented since times with a timezone don't make sense.
e.g. What's the expected behavior for coverting
24:00:00+00:00 to positive UTC offset?The only dependency is pytz. We recommend that you use the latest version of pytz, but this package will not force that upon you.
- datetime_tz
- Another timezone aware drop-in replacement for the
datetimemodule, but overrides more datetime behavior - arrow
- An API-compatible re-write of the
datetimemodule