Skip to main content

Datetimes for Humans.

Project description

Datetimes are very frustrating to work with in Python, especially when dealing with different locales on different systems. This library exists to make the simple things much easier, while admitting that time is an illusion (timezones doubly so).

Datetimes should be interacted with via an API written for humans.

Maya is mostly built around the headaches and use-cases around parsing datetime data from websites.

☤ Basic Usage of Maya

Behold, datetimes for humans!

>>> now = maya.now()
<MayaDT epoch=1481850660.9>

>>> tomorrow = maya.when('tomorrow')
<MayaDT epoch=1481919067.23>

>>> tomorrow.slang_date()
'tomorrow'

>>> tomorrow.slang_time()
'23 hours from now'

>>> tomorrow.iso8601()
'2016-12-16T15:11:30.263350Z'

>>> tomorrow.rfc2822()
'Fri, 16 Dec 2016 20:11:30 -0000'

>>> tomorrow.datetime()
datetime.datetime(2016, 12, 16, 15, 11, 30, 263350, tzinfo=<UTC>)

# Automatically parse datetime strings and generate naive datetimes.
>>> scraped = '2016-12-16 18:23:45.423992+00:00'
>>> maya.parse(scraped).datetime(to_timezone='US/Eastern', naive=True)
datetime.datetime(2016, 12, 16, 13, 23, 45, 423992)

>>> rand_day = maya.when('2011-02-07', timezone='US/Eastern')
<MayaDT epoch=1297036800.0>

# Note how this is the 6th, not the 7th.
>>> rand_day.day
6

# Always.
>>> rand_day.timezone
UTC

☤ Why is this useful?

  • All timezone algebra will behave identically on all machines, regardless of system locale.

  • Complete symmetric import and export of both ISO 8601 and RFC 2822 datetime stamps.

  • Fantastic parsing of both dates written for/by humans and machines (maya.when() vs maya.parse()).

  • Support for human slang, both import and export (e.g. an hour ago).

  • Datetimes can very easily be generated, with or without tzinfo attached.

  • This library is based around epoch time, but dates before Jan 1 1970 are indeed supported, via negative integers.

  • Maya never panics, and always carries a towel.

☤ What about Delorean, Arrow, & Pendulum?

Arrow, for example, is a fantastic library, but isn’t what I wanted in a datetime library. In many ways, it’s better than Maya for certain things. In some ways, in my opinion, it’s not.

I simply desire a sane API for datetimes that made sense to me for all the things I’d ever want to do—especially when dealing with timezone algebra. Arrow doesn’t do all of the things I need (but it does a lot more!). Maya does do exactly what I need.

I think these projects complement each-other, personally. Maya is great for parsing websites. For example- Arrow supports floors and ceilings and spans of dates, which Maya does not at all.

☤ Installing Maya

Installation is easy, with pip:

$ pip install maya

✨🍰✨

☤ Like it?

Say Thanks!

Project details


Download files

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

Source Distribution

maya-0.1.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

maya-0.1.3-py2-none-any.whl (6.6 kB view details)

Uploaded Python 2

File details

Details for the file maya-0.1.3.tar.gz.

File metadata

  • Download URL: maya-0.1.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for maya-0.1.3.tar.gz
Algorithm Hash digest
SHA256 be84775e640feee3e0e1db2346bc8f4806f4f18c748487bd5d84ff6c7e596e1a
MD5 521c8f922d2d72195b7e402ec0674dab
BLAKE2b-256 707095edfa7786a5c46a3277fd8cb4fdb09dae8c874eb6f8a2c8e74aac1fe079

See more details on using hashes here.

Provenance

File details

Details for the file maya-0.1.3-py2-none-any.whl.

File metadata

File hashes

Hashes for maya-0.1.3-py2-none-any.whl
Algorithm Hash digest
SHA256 e714c5cca8cf69d558a7949a1134857f1df24338ab451f4fc6e235bcda7c0a75
MD5 e5a49eec638109387c9381e3f4fd85d9
BLAKE2b-256 f7d2f127f0fd1ff2f1ef5c52649bdf5c9cea3e747030a4e09cda4eefb2eb13eb

See more details on using hashes here.

Provenance

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