{"id":13472420,"url":"https://github.com/ariebovenberg/whenever","last_synced_at":"2026-04-05T20:04:11.088Z","repository":{"id":207644705,"uuid":"717223794","full_name":"ariebovenberg/whenever","owner":"ariebovenberg","description":"⏰ Modern datetime library for Python","archived":false,"fork":false,"pushed_at":"2026-04-02T18:14:45.000Z","size":5035,"stargazers_count":2319,"open_issues_count":10,"forks_count":33,"subscribers_count":10,"default_branch":"main","last_synced_at":"2026-04-02T18:23:31.014Z","etag":null,"topics":["cpython","datetime","mypy","pure-python","pypy","python","rfc3339","rust","timezones","type-safe","utc","utc-offsets"],"latest_commit_sha":null,"homepage":"https://whenever.rtfd.io","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/ariebovenberg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-10T21:08:49.000Z","updated_at":"2026-04-02T10:43:29.000Z","dependencies_parsed_at":"2023-11-16T22:06:11.422Z","dependency_job_id":"11333510-7090-4ded-8367-0b366f24cb5b","html_url":"https://github.com/ariebovenberg/whenever","commit_stats":null,"previous_names":["ariebovenberg/whenever"],"tags_count":76,"template":false,"template_full_name":null,"purl":"pkg:github/ariebovenberg/whenever","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariebovenberg%2Fwhenever","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariebovenberg%2Fwhenever/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariebovenberg%2Fwhenever/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariebovenberg%2Fwhenever/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ariebovenberg","download_url":"https://codeload.github.com/ariebovenberg/whenever/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariebovenberg%2Fwhenever/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31448219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T15:22:31.103Z","status":"ssl_error","status_checked_at":"2026-04-05T15:22:00.205Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cpython","datetime","mypy","pure-python","pypy","python","rfc3339","rust","timezones","type-safe","utc","utc-offsets"],"created_at":"2024-07-31T16:00:54.505Z","updated_at":"2026-04-05T20:04:11.083Z","avatar_url":"https://github.com/ariebovenberg.png","language":"Python","funding_links":[],"categories":["Python","Date \u0026 Time","Utilities"],"sub_categories":[],"readme":"# ⏰ Whenever\n\n[![](https://img.shields.io/pypi/v/whenever.svg?color=blue)](https://pypi.python.org/pypi/whenever)\n[![](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fariebovenberg%2Fwhenever%2Fmain%2Fpyproject.toml)](https://pypi.python.org/pypi/whenever)\n[![](https://img.shields.io/pypi/l/whenever.svg?color=blue)](https://pypi.python.org/pypi/whenever)\n[![](https://img.shields.io/github/actions/workflow/status/ariebovenberg/whenever/checks.yml?branch=main)](https://github.com/ariebovenberg/whenever)\n[![](https://img.shields.io/readthedocs/whenever.svg)](http://whenever.readthedocs.io/)\n[![](https://img.shields.io/pypi/dm/whenever)](https://pypi.python.org/pypi/whenever)\n\n\n**Typed and DST-safe datetimes for Python, available in Rust or pure Python.**\n\nDo you cross your fingers every time you work with Python's datetime—hoping that you didn't mix naive and aware?\nor that you avoided its [other pitfalls](https://dev.arie.bovenberg.net/blog/python-datetime-pitfalls/)?\nThere’s no way to be sure...\n\n✨ Until now! ✨\n\n*Whenever* helps you write **correct** and **type checked** datetime code,\nusing **well-established concepts** from [modern libraries](#acknowledgements) in other languages.\nIt's also **way faster** than other third-party libraries, and usually the standard library as well.\nDon't buy the Rust hype?—don't worry: a **pure Python** version is available as well.\n\n  \u003cp align=\"center\"\u003e\n    \u003cpicture align=\"center\"\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/ariebovenberg/whenever/main/benchmarks/comparison/graph-dark.svg\"\u003e\n        \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/ariebovenberg/whenever/main/benchmarks/comparison/graph-light.svg\"\u003e\n        \u003cimg alt=\"Shows a bar chart with benchmark results.\" src=\"https://raw.githubusercontent.com/ariebovenberg/whenever/main/benchmarks/comparison/graph-light.svg\"\u003e\n    \u003c/picture\u003e\n  \u003c/p\u003e\n\n  \u003cp align=\"center\" style=\"font-size: 14px\"\u003e\n    \u003ci\u003eParse, normalize, compare to now, shift, change timezone, and format (1M times)\u003c/i\u003e\n  \u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n\n[📖 Docs](https://whenever.readthedocs.io) |\n[🐍 PyPI](https://pypi.org/project/whenever/) |\n[🚀 Changelog](https://whenever.readthedocs.io/en/latest/changelog.html) |\n[❓ FAQ](https://whenever.readthedocs.io/en/latest/faq.html) |\n[🐛 Issues](https://github.com/ariebovenberg/whenever/issues) |\n[💬 Q\u0026A](https://github.com/ariebovenberg/whenever/discussions)\n\n\u003c/div\u003e\n\n\u003e ⚠️ Note: Holding off on 1.0 a little longer so we can get the API just\n\u003e right for the long term—feedback (especially on durations) is still very welcome.\n\u003e Leave a ⭐️ on GitHub if you'd like to see how this project develops!\n\n## Why not the standard library?\n\nOver 20+ years, Python's `datetime` has grown\nout of step with what you'd expect from a modern datetime library.\nTwo points stand out:\n\n1. **It doesn't always account for Daylight Saving Time (DST)**.\n   Here is a simple example:\n\n   ```python\n   bedtime = datetime(2023, 3, 25, 22, tzinfo=ZoneInfo(\"Europe/Paris\"))\n   full_rest = bedtime + timedelta(hours=8)\n   # It returns 6am, but should be 7am—because we skipped an hour due to DST!\n   ```\n\n   Note this isn't a bug, but a design decision that DST is only considered\n   when calculations involve *two* timezones.\n   If you think this is surprising, you\n   [are](https://github.com/python/cpython/issues/91618)\n   [not](https://github.com/python/cpython/issues/116035)\n   [alone](https://github.com/python/cpython/issues/112638).\n\n2. **Typing can't distinguish between naive and aware datetimes**.\n   Your code probably only works with one or the other,\n   but there's no way to enforce this in the type system!\n\n   ```python\n   # Does this expect naive or aware? Can't tell!\n   def schedule_meeting(at: datetime) -\u003e None: ...\n   ```\n\n## Why not other libraries?\n\nThere are two other popular third-party libraries, but they don't (fully)\naddress these issues. Here's how they compare to *whenever* and the standard library:\n\n\u003cdiv align=\"center\"\u003e\n\n|                   | Whenever | datetime | Arrow | Pendulum |\n|-------------------|:--------:|:--------:|:-----:|:--------:|\n|      DST-safe     |     ✅    |     ❌    |   ❌   |     ⚠️    |\n| Typed aware/naive |     ✅    |     ❌    |   ❌   |     ❌    |\n|        Fast       |     ✅    |     ✅    |   ❌   |     ❌    |\n\n\u003c/div\u003e\n\n[**Arrow**](https://pypi.org/project/arrow/)\nis probably the most historically popular 3rd party datetime library.\nIt attempts to provide a more \"friendly\" API than the standard library,\nbut doesn't address the core issues:\nit keeps the same footguns, and its decision to reduce the number\nof types to just one (``arrow.Arrow``) means that it's even harder\nfor typecheckers to catch mistakes.\n\n[**Pendulum**](https://pypi.org/project/pendulum/)\narrived on the scene in 2016, promising better DST-handling,\nas well as improved performance.\nHowever, it only fixes [*some* DST-related pitfalls](https://dev.arie.bovenberg.net/blog/python-datetime-pitfalls/#datetime-library-scorecard),\nand its performance has significantly [degraded over time](https://github.com/sdispater/pendulum/issues/818).\nAdditionally, it's in a long maintenance slump with only two releases in the last four years,\nwhile many serious and long-standing issues remain unaddressed.\n\n## Why use whenever?\n\n- 🌐 DST-safe arithmetic\n- 🛡️ Typesafe API prevents common bugs\n- ✅ Fixes issues [arrow/pendulum don't](https://dev.arie.bovenberg.net/blog/python-datetime-pitfalls/#datetime-library-scorecard)\n- ⚖️  Based on proven and [familiar concepts](https://www.youtube.com/watch?v=saeKBuPewcU)\n- ⚡️ Unmatched performance\n- 💎 Thoroughly tested and documented\n- 📆 Support for date arithmetic\n- ⏱️ Nanosecond precision\n- 🗄️ [SQLAlchemy support](https://pypi.org/project/whenever-sqlalchemy/)\n- 🪃 Pydantic support (beta)\n- 🦀 Rust!—but with a [pure-Python option](https://whenever.readthedocs.io/en/latest/faq.html#how-can-i-use-the-pure-python-version)\n- 🧵 Free-threading support (beta)\n- 🚀 Supports per-interpreter GIL\n\n## Quickstart\n\n```python\n\u003e\u003e\u003e from whenever import (\n...    # Explicit types for different use cases\n...    Instant,\n...    ZonedDateTime,\n...    PlainDateTime,\n... )\n\n# Identify moments in time, without timezone/calendar complexity\n\u003e\u003e\u003e now = Instant.now()\nInstant(\"2024-07-04 10:36:56Z\")\n\n# Simple, explicit conversions\n\u003e\u003e\u003e now.to_tz(\"Europe/Paris\")\nZonedDateTime(\"2024-07-04 12:36:56+02:00[Europe/Paris]\")\n\n# A 'naive' datetime can't accidentally mix with other types.\n# You need to explicitly convert it and handle ambiguity.\n\u003e\u003e\u003e party_invite = PlainDateTime(\"2023-10-28 22:00\")\n\u003e\u003e\u003e party_invite.add(hours=6)\n  NaiveArithmeticWarning: Adjusting a local time ignores DST [...]\nPlainDateTime(\"2023-10-29 04:00\")\n\u003e\u003e\u003e party_starts = party_invite.assume_tz(\"Europe/Amsterdam\")\nZonedDateTime(\"2023-10-28 22:00:00+02:00[Europe/Amsterdam]\")\n\n# DST-safe arithmetic\n\u003e\u003e\u003e party_starts.add(hours=6)\nZonedDateTime(\"2023-10-29 03:00:00+01:00[Europe/Amsterdam]\")\n\n# Comparison and equality\n\u003e\u003e\u003e now \u003e party_starts\nTrue\n\n# Rounding and truncation\n\u003e\u003e\u003e now.round(\"minute\", increment=15)\nInstant(\"2024-07-04 10:30:00Z\")\n\n# Formatting \u0026 parsing common formats (ISO8601, RFC3339, RFC2822)\n\u003e\u003e\u003e now.format_rfc2822()\n\"Thu, 04 Jul 2024 10:36:56 GMT\"\n# Custom pattern formatting and parsing\n\u003e\u003e\u003e party_starts.format(\"MMM DD, hh:mm zz\")\n\"Oct 28, 22:00 CEST\"\n\n# If you must: you can convert to/from the standard lib\n\u003e\u003e\u003e now.to_stdlib()\ndatetime.datetime(2024, 7, 4, 10, 36, 56, tzinfo=datetime.timezone.utc)\n```\n\nRead more in the [feature overview](https://whenever.readthedocs.io/en/latest/guide/choosing-a-type.html)\nor [API reference](https://whenever.readthedocs.io/en/latest/reference/datetime.html).\n\n## Limitations\n\n- Supports the proleptic Gregorian calendar between 1 and 9999 AD\n- Timezone offsets are limited to whole seconds (consistent with IANA TZ DB)\n\n## Stability policy\n\n*Whenever* follows semantic versioning.\nUntil the 1.0 version, the API may change with minor releases.\nBreaking changes will be meticulously explained in the changelog.\nSince the API is fully typed, your typechecker and/or IDE\nwill help you adjust to any API changes.\n\n## License\n\n*Whenever* is licensed under the MIT License.\nThe binary wheels contain Rust dependencies which are licensed under\nsimilarly permissive licenses (MIT, Apache-2.0, and others).\nFor more details, see the licenses included in the distribution.\n\n## Acknowledgements\n\n*Whenever* draws from decades of datetime library design across multiple languages:\n\n- **[Noda Time](https://nodatime.org/)** and **[Joda Time](https://www.joda.org/joda-time/)**\n  pioneered the concept-per-type approach that makes *whenever* possible.\n  Noda Time's type hierarchy directly inspired *whenever*'s design.\n\n- **[Temporal](https://tc39.es/proposal-temporal/docs/)** (JavaScript proposal)\n  provided inspiration for handling complex cases around DST ambiguity and rounding.\n  After years of TC39 design work, Temporal's API\n  is extraordinarily thorough. *Whenever* benefits from those hard-won insights.\n\n- **Python's `datetime` module** is used extensively in *whenever*'s pure-Python implementation\n  for low-level date/time handling.\n\n- *Whenever* also borrows a few nifty ideas from [Jiff](https://github.com/BurntSushi/jiff):\n  A modern datetime library in Rust which takes inspiration from Temporal.\n\n- The benchmark comparison graph is adapted from the [Ruff](https://github.com/astral-sh/ruff) project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fariebovenberg%2Fwhenever","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fariebovenberg%2Fwhenever","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fariebovenberg%2Fwhenever/lists"}