All Projects → timofurrer → Maya

timofurrer / Maya

Licence: mit
Datetimes for Humans™

Programming Languages

python
139335 projects - #7 most used programming language
Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to Maya

Moment.php
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Stars: ✭ 900 (-72.71%)
Mutual labels:  parsing, time, date
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (-39.87%)
Mutual labels:  time, date, dates
Delorean
Delorean: Time Travel Made Easy
Stars: ✭ 1,793 (-45.63%)
Mutual labels:  time, date, datetimes
Gostradamus
Gostradamus: Better DateTimes for Go 🕰️
Stars: ✭ 148 (-95.51%)
Mutual labels:  parsing, time, date
rescript-date
📆 Date manipulation in ReScript.
Stars: ✭ 101 (-96.94%)
Mutual labels:  time, date
chronos
One library to rule the time
Stars: ✭ 17 (-99.48%)
Mutual labels:  time, date
Timestamp
⏰ A better macOS menu bar clock.
Stars: ✭ 296 (-91.02%)
Mutual labels:  time, date
Md Date Time Picker
An implementation of Material Design Picker components in vanilla CSS, JS, and HTML
Stars: ✭ 272 (-91.75%)
Mutual labels:  time, date
shamsi date
A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) date and times.
Stars: ✭ 59 (-98.21%)
Mutual labels:  time, date
moment-cache
⏱ Simple utility to cache moment.js results and speed up moment calls.
Stars: ✭ 29 (-99.12%)
Mutual labels:  time, date
nepali-datetime
Python's core datetime inspired nepali datetime (BS date & NPT) package 🇳🇵
Stars: ✭ 36 (-98.91%)
Mutual labels:  time, date
time-formater
在javascript中显示日期。
Stars: ✭ 44 (-98.67%)
Mutual labels:  time, date
popoPicker
popoPicker是一个移动端3D滚轮日期时间和单项的选择器,支持无限循环滚动,不依赖第三方库
Stars: ✭ 26 (-99.21%)
Mutual labels:  time, date
react-picky-date-time
A react component for date time picker. Online demo examples
Stars: ✭ 41 (-98.76%)
Mutual labels:  time, date
relative.time.parser
Moment.js Plugin for parsing Relative Time Strings
Stars: ✭ 13 (-99.61%)
Mutual labels:  time, date
vue-timeselector
🕒 Simply customizable powerful time picker for Vue.js
Stars: ✭ 41 (-98.76%)
Mutual labels:  time, date
date-php
这是一个Javascript模仿PHP日期时间格式化函数,使用方法和PHP非常类似,有丰富的模板字符,并在原来的基础上增加了一些模板字符。 This is a date function that implement PHP in Javascript. It is very similar to PHP, has rich template characters, and enhances some template characters on the basis of the original.
Stars: ✭ 24 (-99.27%)
Mutual labels:  time, date
date4j
Lightweight alternative to Java's built-in date-time classes. Android-friendly. Compiles under JDK 1.5.
Stars: ✭ 36 (-98.91%)
Mutual labels:  time, date
Awesome Falsehood
😱 Falsehoods Programmers Believe in
Stars: ✭ 16,614 (+403.76%)
Mutual labels:  time, date
react-ago-component
A component for React that renders the approximate time ago in words from a specific past date using an HTML5 time element.
Stars: ✭ 25 (-99.24%)
Mutual labels:  time, date

Maya: Datetimes for Humans™

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'

# Also: MayaDT.from_iso8601(...)
>>> tomorrow.iso8601()
'2017-02-10T22:17:01.445418Z'

# Also: MayaDT.from_rfc2822(...)
>>> tomorrow.rfc2822()
'Fri, 10 Feb 2017 22:17:01 GMT'

# Also: MayaDT.from_rfc3339(...)
>>> tomorrow.rfc3339()
'2017-02-10T22:17:01.44Z'

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

# Maya speaks Python.
>>> m = maya.MayaDT.from_datetime(datetime.utcnow())
>>> print(m)
Wed, 20 Sep 2017 17:24:32 GMT

>>> m = maya.MayaDT.from_struct(time.gmtime())
>>> print(m)
Wed, 20 Sep 2017 17:24:32 GMT

>>> m = maya.MayaDT(time.time())
>>> print(m)
Wed, 20 Sep 2017 17:24:32 GMT

>>> rand_day.day
7

>>> rand_day.add(days=10).day
17

# Always.
>>> rand_day.timezone
UTC

# Range of hours in a day:
>>> maya.intervals(start=maya.now(), end=maya.now().add(days=1), interval=60*60)
<generator object intervals at 0x105ba5820>

# snap modifiers
>>> dt = maya.when('Mon, 21 Feb 1994 21:21:42 GMT')
>>> dt.snap('@d+3h').rfc2822()
'Mon, 21 Feb 1994 03:00:00 GMT'

    # snap modifiers within a timezone
>>> dt = maya.when('Mon, 21 Feb 1994 21:21:42 GMT')
>>> dt.snap_tz('+3h@d', 'Australia/Perth').rfc2822()
    'Mon, 21 Feb 1994 16:00:00 GMT'

☤ Advanced Usage of Maya

In addition to timestamps, Maya also includes a wonderfully powerful MayaInterval class, which represents a range of time (e.g. an event). With this class, you can perform a multitude of advanced calendar calculations with finesse and ease.

For example:

>>> from maya import MayaInterval

# Create an event that is one hour long, starting now.
>>> event_start = maya.now()
>>> event_end = event_start.add(hours=1)

>>> event = MayaInterval(start=event_start, end=event_end)

From here, there are a number of methods available to you, which you can use to compare this event to another event.

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

All these projects complement each other, and are friends. Pendulum, for example, helps power Maya's parsing.

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, and dealing with calendar events!

☤ Installing Maya

Installation is easy, with:

$ pip install maya

How to Contribute

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
  2. Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).
  3. Write a test which shows that the bug was fixed or that the feature works as expected.
  4. Send a pull request and bug the maintainer until it gets merged and published. :)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].