{"id":30318254,"url":"https://github.com/timofurrer/maya","last_synced_at":"2025-08-17T20:09:52.723Z","repository":{"id":38291287,"uuid":"76606572","full_name":"kennethreitz/maya","owner":"kennethreitz","description":"Datetimes for Humans™","archived":false,"fork":false,"pushed_at":"2024-07-19T13:04:30.000Z","size":360,"stargazers_count":3411,"open_issues_count":20,"forks_count":196,"subscribers_count":66,"default_branch":"master","last_synced_at":"2025-08-15T10:05:25.174Z","etag":null,"topics":["date","dates","datetimes","forhumans","kennethreitz","parsing","python","time","times"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kennethreitz.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-16T00:16:04.000Z","updated_at":"2025-08-13T14:35:28.000Z","dependencies_parsed_at":"2024-04-10T14:01:51.436Z","dependency_job_id":"9cdb5335-3397-4575-9523-d3b5cd0e4ee1","html_url":"https://github.com/kennethreitz/maya","commit_stats":{"total_commits":279,"total_committers":47,"mean_commits":"5.9361702127659575","dds":0.5627240143369175,"last_synced_commit":"b12a8dad11aec99ef62b063b5631dce0f528bcb4"},"previous_names":["kennethreitz/maya","timofurrer/maya"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/kennethreitz/maya","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethreitz%2Fmaya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethreitz%2Fmaya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethreitz%2Fmaya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethreitz%2Fmaya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kennethreitz","download_url":"https://codeload.github.com/kennethreitz/maya/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethreitz%2Fmaya/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270899582,"owners_count":24664720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","dates","datetimes","forhumans","kennethreitz","parsing","python","time","times"],"created_at":"2025-08-17T20:04:28.233Z","updated_at":"2025-08-17T20:09:52.710Z","avatar_url":"https://github.com/kennethreitz.png","language":"Python","readme":"Maya: Datetimes for Humans™\n===========================\n\n.. image:: https://img.shields.io/pypi/v/maya.svg\n    :target: https://pypi.python.org/pypi/maya\n\n.. image:: https://github.com/timofurrer/maya/workflows/Continuous%20Integration%20and%20Deployment/badge.svg\n    :target: https://github.com/timofurrer/maya/actions\n\n\nDatetimes are very frustrating to work with in Python, especially when dealing\nwith different locales on different systems. This library exists to make the\nsimple things **much** easier, while admitting that time is an illusion\n(timezones doubly so).\n\nDatetimes should be interacted with via an API written for humans.\n\nMaya is mostly built around the headaches and use-cases around parsing datetime data from websites.\n\n\n☤ Basic Usage of Maya\n---------------------\n\nBehold, datetimes for humans!\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e now = maya.now()\n    \u003cMayaDT epoch=1481850660.9\u003e\n\n    \u003e\u003e\u003e tomorrow = maya.when('tomorrow')\n    \u003cMayaDT epoch=1481919067.23\u003e\n\n    \u003e\u003e\u003e tomorrow.slang_date()\n    'tomorrow'\n\n    \u003e\u003e\u003e tomorrow.slang_time()\n    '23 hours from now'\n\n    # Also: MayaDT.from_iso8601(...)\n    \u003e\u003e\u003e tomorrow.iso8601()\n    '2017-02-10T22:17:01.445418Z'\n\n    # Also: MayaDT.from_rfc2822(...)\n    \u003e\u003e\u003e tomorrow.rfc2822()\n    'Fri, 10 Feb 2017 22:17:01 GMT'\n\n    # Also: MayaDT.from_rfc3339(...)\n    \u003e\u003e\u003e tomorrow.rfc3339()\n    '2017-02-10T22:17:01.44Z'\n\n    \u003e\u003e\u003e tomorrow.datetime()\n    datetime.datetime(2016, 12, 16, 15, 11, 30, 263350, tzinfo=\u003cUTC\u003e)\n\n    # Automatically parse datetime strings and generate naive datetimes.\n    \u003e\u003e\u003e scraped = '2016-12-16 18:23:45.423992+00:00'\n    \u003e\u003e\u003e maya.parse(scraped).datetime(to_timezone='US/Eastern', naive=True)\n    datetime.datetime(2016, 12, 16, 13, 23, 45, 423992)\n\n    \u003e\u003e\u003e rand_day = maya.when('2011-02-07', timezone='US/Eastern')\n    \u003cMayaDT epoch=1297036800.0\u003e\n\n    # Maya speaks Python.\n    \u003e\u003e\u003e m = maya.MayaDT.from_datetime(datetime.utcnow())\n    \u003e\u003e\u003e print(m)\n    Wed, 20 Sep 2017 17:24:32 GMT\n\n    \u003e\u003e\u003e m = maya.MayaDT.from_struct(time.gmtime())\n    \u003e\u003e\u003e print(m)\n    Wed, 20 Sep 2017 17:24:32 GMT\n\n    \u003e\u003e\u003e m = maya.MayaDT(time.time())\n    \u003e\u003e\u003e print(m)\n    Wed, 20 Sep 2017 17:24:32 GMT\n\n    \u003e\u003e\u003e rand_day.day\n    7\n\n    \u003e\u003e\u003e rand_day.add(days=10).day\n    17\n\n    # Always.\n    \u003e\u003e\u003e rand_day.timezone\n    UTC\n\n    # Range of hours in a day:\n    \u003e\u003e\u003e maya.intervals(start=maya.now(), end=maya.now().add(days=1), interval=60*60)\n    \u003cgenerator object intervals at 0x105ba5820\u003e\n\n    # snap modifiers\n    \u003e\u003e\u003e dt = maya.when('Mon, 21 Feb 1994 21:21:42 GMT')\n    \u003e\u003e\u003e dt.snap('@d+3h').rfc2822()\n    'Mon, 21 Feb 1994 03:00:00 GMT'\n\n\t# snap modifiers within a timezone\n    \u003e\u003e\u003e dt = maya.when('Mon, 21 Feb 1994 21:21:42 GMT')\n    \u003e\u003e\u003e dt.snap_tz('+3h@d', 'Australia/Perth').rfc2822()\n\t'Mon, 21 Feb 1994 16:00:00 GMT'\n\n☤ Advanced Usage of Maya\n------------------------\n\nIn 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.\n\nFor example:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e from maya import MayaInterval\n\n    # Create an event that is one hour long, starting now.\n    \u003e\u003e\u003e event_start = maya.now()\n    \u003e\u003e\u003e event_end = event_start.add(hours=1)\n\n    \u003e\u003e\u003e event = MayaInterval(start=event_start, end=event_end)\n\nFrom here, there are a number of methods available to you, which you can use to compare this event to another event.\n\n\n\n☤ Why is this useful?\n---------------------\n\n- All timezone algebra will behave identically on all machines, regardless of system locale.\n- Complete symmetric import and export of both ISO 8601 and RFC 2822 datetime stamps.\n- Fantastic parsing of both dates written for/by humans and machines (``maya.when()`` vs ``maya.parse()``).\n- Support for human slang, both import and export (e.g. `an hour ago`).\n- Datetimes can very easily be generated, with or without tzinfo attached.\n- This library is based around epoch time, but dates before Jan 1 1970 are indeed supported, via negative integers.\n- Maya never panics, and always carries a towel.\n\n\n☤ What about Delorean_, Arrow_, \u0026 Pendulum_?\n--------------------------------------------\n\nAll these projects complement each other, and are friends. Pendulum, for example, helps power Maya's parsing.\n\nArrow, 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.\n\nI 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.\n\nI think these projects complement each-other, personally. Maya is great for parsing websites, and dealing with calendar events!\n\n.. _Delorean: https://delorean.readthedocs.io/\n.. _Arrow: https://arrow.readthedocs.io/\n.. _Pendulum: https://pendulum.eustace.io/\n\n\n☤ Installing Maya\n-----------------\n\nInstallation is easy, with:\n\n    $ pip install maya\n\n\nHow to Contribute\n-----------------\n\n#. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.\n#. Fork `the repository`_ on GitHub to start making your changes to the **master** branch (or branch off of it).\n#. Write a test which shows that the bug was fixed or that the feature works as expected.\n#. Send a pull request and bug the maintainer until it gets merged and published. :)\n\n.. _`the repository`: http://github.com/timofurrer/maya\n","funding_links":[],"categories":["Time Series","Libraries","Date and Time","Python","📦 Packages","日期和时间","Date and Time [🔝](#readme)","📚 فهرست"],"sub_categories":["Others","NLP","Python","Automatic Plotting","کار با زمان و تقویم"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimofurrer%2Fmaya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimofurrer%2Fmaya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimofurrer%2Fmaya/lists"}