Skip to main content

Drop-in replacement for timezone aware datetime objects

Project description

Build Status

awaredatetime

Module providing a timezone aware datetime.datetime compatible object. Supports CPython 2.6 - 3.5 and PyPy.

Motivation

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.

awaredatetime.AwareDatetime

A drop-in replacement for datetime.datetime that always provide timezone aware objects.

Example Usage

>>> 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>)
>>>

awaredatetime.AwareTime

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?

Dependencies

The only dependency is pytz. We recommend that you use the latest version of pytz, but this package will not force that upon you.

Migrating Existing Code

Similar work

  • datetime_tz - Another timezone aware drop-in replacement for the datetime module, but overrides more datetime behavior

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

awaredatetime-0.0.1-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file awaredatetime-0.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for awaredatetime-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9636fa550ee9442aa26797ef88e0fed5497fa5f6a06940185751f7b0b652d810
MD5 4b83570e543e0d0f4b5fd26ad96f3b16
BLAKE2b-256 e7f3f8cb89ea179fd4794f605de7a5957f26aa37f4c1b1bcf49d3813bc918e02

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page