whenever
Modern datetime library for Python
What it is and what it does
Whenever is a modern datetime library that addresses two core limitations of Python's standard library: it handles Daylight Saving Time correctly during arithmetic operations (e.g., adding hours across a DST boundary), and it uses distinct types to enforce type-safe distinction between naive and aware datetimes at compile time. The library provides three main types—Instant (UTC moments), ZonedDateTime (timezone-aware local times), and PlainDateTime (naive local times)—each with explicit semantics that prevent accidental mixing.
The package is available in two implementations: a Rust-backed version for performance and a pure-Python fallback for compatibility. It supports nanosecond precision, date arithmetic, common datetime formats (ISO8601, RFC3339, RFC2822), and integration with SQLAlchemy and Pydantic. The API is fully typed and follows semantic versioning; until version 1.0, minor releases may introduce breaking changes, though the type system helps identify necessary adjustments.
Use it for:
- Schedule events across DST transitions without silent hour-skipping bugs.
- Enforce type safety in APIs where functions must work only with aware or only with naive datetimes.
- Parse and format datetimes in standard formats (ISO8601, RFC2822) with full timezone awareness.
- Perform timezone conversions and comparisons with correct DST handling.
- Build datetime-heavy applications (e.g., scheduling, logging) where correctness is critical.
- Migrate from Arrow or Pendulum when DST correctness and type safety become requirements.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Whenever provides type-safe, DST-aware datetime handling for Python with explicit types that distinguish naive from aware datetimes, available as a Rust-backed or pure-Python implementation.
Yes. Whenever solves real, well-documented pitfalls in Python's datetime module—particularly DST arithmetic and type safety—that affect any application working with timezones. It has low install friction, active maintenance, no known vulnerabilities, and permissive licensing. The API is pre-1.0 and may change, but type checking will catch those changes. Install it if you work with timezones or need to prevent datetime mixing bugs; skip it only if you never cross timezone boundaries or can tolerate standard library footguns.
Install
whenever on PyPI
pip
pip install wheneveruv
uv add wheneverpoetry
poetry add wheneverInstalling whenever
Before you install
Low friction: pure Python wheel, only two runtime dependencies (tzdata, tzlocal). Actively maintained with a release 7 days ago and 2374 GitHub stars. Supports Python 3.10–3.15 and PyPy.
License in practice
MIT license (permissive). Binary wheels include Rust dependencies under similarly permissive licenses (MIT, Apache-2.0, others), with license details included in distributions.
Quickstart
pip install whenever
from whenever import Instant, ZonedDateTime, PlainDateTime
now = Instant.now()
party = PlainDateTime("2023-10-28 22:00").assume_tz("Europe/Amsterdam")
party_end = party.add(hours=6) # DST-safe arithmetic
Requires Python 3.10 or later.
Verify before relying
- Whether the pure-Python fallback is automatically selected or requires explicit configuration.
- Performance comparison with standard library datetime for typical use cases.
- SQLAlchemy and Pydantic integration maturity beyond 'beta' status.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — tzdata, tzlocal |
| Maintenance | actively maintained — 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,877,731/month — #1,826 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: whenever-0.10.5-py3-none-any.whl
Keywords: datetime, typesafe, rust, date, time, timezone, utc, zoneinfo, tzdata, tzdb
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
datetypeDateType provides type-checking-time wrapper…
unclear · top 15,000 on PyPI
pendulumPendulum provides an enhanced datetime API for…
permissive · top 1,000 on PyPI
SQLAlchemy-UtcProvides a SQLAlchemy DateTime type that…
permissive · top 15,000 on PyPI
timesTimes converts between universal (UTC) time and…
permissive · top 15,000 on PyPI
pytzpytz brings the Olson timezone database into…
permissive · top 100 on PyPI
backports.zoneinfoProvides IANA time zone support for Python…
permissive · top 5,000 on PyPI
dateformatParses strings into datetime objects and…
permissive · top 15,000 on PyPI
iso8601Parses ISO 8601 date strings (e.g.…
permissive · top 5,000 on PyPI
udatetimeudatetime provides fast RFC3339-compliant…
permissive · top 15,000 on PyPI
DateTimeRangeDateTimeRange creates and manipulates time…
permissive · top 15,000 on PyPI