Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Dayjs | 44,173 | 5,371 | 11,414 | 3 days ago | 122 | July 01, 2023 | 808 | mit | JavaScript | |
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API | ||||||||||
Date Fns | 32,359 | 68,280 | 11,158 | 3 days ago | 180 | April 30, 2023 | 628 | mit | TypeScript | |
⏳ Modern JavaScript date utility library ⌛️ | ||||||||||
Awesome Falsehood | 22,086 | 13 days ago | 4 | cc0-1.0 | ||||||
😱 Falsehoods Programmers Believe in | ||||||||||
Luxon | 14,260 | 1,936 | 3,121 | 14 days ago | 139 | March 04, 2023 | 144 | mit | JavaScript | |
⏱ A library for working with dates and times in JS | ||||||||||
Arrow | 8,372 | 3,711 | 1,031 | a day ago | 63 | September 03, 2022 | 97 | apache-2.0 | Python | |
🏹 Better dates & times for Python | ||||||||||
Pickadate.js | 7,727 | 172 | 38 | 3 months ago | 18 | May 31, 2019 | 311 | mit | JavaScript | |
The mobile-friendly, responsive, and lightweight jQuery date & time input picker. | ||||||||||
Datetools | 7,089 | 663 | 3 years ago | 13 | September 28, 2017 | 118 | mit | Objective-C | ||
Dates and times made easy in iOS | ||||||||||
Pendulum | 5,711 | 540 | 662 | a day ago | 53 | November 23, 2022 | 229 | mit | Python | |
Python datetimes made easy | ||||||||||
Joda Time | 4,936 | 31,269 | 5,883 | 14 days ago | 58 | March 30, 2023 | 44 | apache-2.0 | Java | |
Joda-Time is the widely used replacement for the Java date and time classes prior to Java SE 8. | ||||||||||
Carbon | 3,479 | 36 | 5 days ago | 112 | November 06, 2022 | 3 | mit | Go | ||
A simple, semantic and developer-friendly golang package for datetime |
Looking for a new maintainer: https://github.com/timofurrer/maya/issues/197
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?
maya.when()
vs maya.parse()
).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 doespecially 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