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.

☤ 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.

☤ 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.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maya-0.1.1-py2-none-any.whl (5.8 kB view details)

Uploaded Python 2

File details

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

File metadata

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

File hashes

Hashes for maya-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fdf8695b460baeda4480853fed4c89613de32a67d601a8981c8cd38f358dfcc6
MD5 9354e57c845b60dc5ca3e00c490082b4
BLAKE2b-256 a46d737ac16cd7710c58512c888c5f382da6b4cdcc9ab9b790f9e5f6514a3c64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maya-0.1.1-py2-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for maya-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 4776fd4236b708b8d8f446e42d95d9ab1b2422853f736e711f25fe348e8d9a0b
MD5 5c6cd9d7ee2a311a0e86ed4ec0cb5602
BLAKE2b-256 319d7e3763f2069066ed30f7c030595900f926f89be28989ad37485fa6fe632b

See more details on using hashes here.

Supported by

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