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'

>>> tomorrrow.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 our 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 carrys a towel.

☤ Installing Maya

Maya hasn’t been released yet, but will be very soon!

✨🍰✨

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.0.tar.gz (2.3 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.0-py2-none-any.whl (3.9 kB view details)

Uploaded Python 2

File details

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

File metadata

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

File hashes

Hashes for maya-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e16e3ba75c89e75fb39ce0c5763445865a26ee291f83026158ca28d4f6cb36e
MD5 ff477e7facee99405e8845189edaedeb
BLAKE2b-256 5560353c21fe84b482d225dd223de50d6a922e5295afe93d3b2d78deec3e1120

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for maya-0.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 4574ed0993ca40a4cfa17e8e63f00c24aa20cdcfe497a17d4744e0f30093f90b
MD5 4449dcc8503e8e3f8a620301395cf7f0
BLAKE2b-256 467bc00d9dde952ee04eea3c8d8e66c524b71773167b9ed6212d6d0c9618c880

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