Skip to main content

dately

Deterministic date, time, timezone, holiday, and natural-language temporal processing for Python.

PyPI version Supported Python versions Downloads Powered by DOYDL Technologies

Overview

dately parses, detects, converts, replaces, and normalizes date and time values. It accepts individual strings as well as lists, dictionaries, NumPy arrays, and pandas Series. Its rule-based NLP engine also resolves expressions such as:

  • first Monday of next month
  • last 5 weekends
  • Q3 of last year
  • 3 days ago starting from April 10

The library includes Cython extensions for frequently used parsing operations and compatibility handling for platform-specific date-format behavior.

Installation

Install the latest published release from PyPI:

python -m pip install dately

To test a local checkout in an isolated environment:

python -m venv .venv-test
source .venv-test/Scripts/activate
python -m pip install --upgrade pip setuptools wheel
python -m pip install -e .
python -m pytest -q

Release downloads provide Windows x64 wheels for supported CPython versions and a source distribution. See Distribution builds for the artifact matrix and release procedure.

Quick start

import dately as dtly

dtly.detect_date_format("2024-03-13T14:30:00")
# '%Y-%m-%dT%H:%M:%S'

dtly.replace_datestring(
    "2024-03-13T14:30:00",
    year=2025,
    month=12,
    day=25,
)
# '2025-12-25T14:30:00'

dtly.replace_timestring(
    "2024-03-13 T14:30:00",
    hour=9,
    minute=15,
    tzinfo="Europe/London",
)
# '2024-03-13 T09:15:00 Europe/London'

dtly.parse("first Monday of next month")
# datetime.date(...) relative to the current date

Capabilities

Format detection and conversion

  • Detect common and custom date/time formats.
  • Convert values to a requested output format.
  • Extract individual year, month, day, time, and timezone components.
  • Process scalar values and nested collections.

Date and time replacement

  • Replace selected date or time components without rebuilding the input manually.
  • Preserve the original date/time separator where supported.
  • Work with ISO-8601 and non-ISO strings.

Natural-language parsing

  • Resolve relative, ordinal, anchored, and range expressions.
  • Interpret quarters, weeks, weekends, weekdays, months, and years.
  • Configure the first day of the week with set_week_start().
  • Return exact dates or date ranges through a deterministic rule-based pipeline.

Timezones and holidays

TimeZoner and Holidate are exposed as lazy-loaded public objects:

import dately as dtly

country_codes = dtly.TimeZoner.CountryCodes
zones = dtly.TimeZoner.Zones
holidays = dtly.Holidate

Bundled timezone and holiday properties work with local data. Operations that request current remote information still depend on their respective external services being available. See the issue and fix log for implementation details.

Cross-platform formatting

Windows and Unix-like platforms differ in their support for flags that suppress leading zeros in strftime directives. dately detects and normalizes these cases so formatting behavior remains consistent across supported platforms.

Examples

Runnable examples with expected output are available in the examples directory:

Documentation

License

dately is distributed under the MIT License. See LICENSE for details.

Release files for dately 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dately 3.3.0
File Size Uploaded
dately-3.3.0.tar.gz 2.0 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for dately 3.3.0
File
dately-3.3.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
dately-3.3.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
dately-3.3.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
dately-3.3.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
dately-3.3.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
dately-3.3.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
dately-3.3.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details

Total release size: 4.9 MB

Release files / dately-3.3.0.tar.gz

Download URL dately-3.3.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
1ab3c4f90fe6905ea0cdfd765c388f036b0935d8cf19af981af0c7e4cddbf609
BLAKE2b-256 checksum
How to use checksums
265ac20d90554ad9e466e71af903b58af9375a9a6a166b36f3c5a63dd343f710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dately-3.3.0-cp314-cp314-win_amd64.whl

Download URL dately-3.3.0-cp314-cp314-win_amd64.whl
Size 422.4 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
a80ffaf453c04f1ff1c3a0e17ed06d7f18774977e0c5499545c6a5e470727ba4
BLAKE2b-256 checksum
How to use checksums
65c5688947483dc72ba4e1bcc3baa60c0b45519f33940e365c73cc08f43e21b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dately-3.3.0-cp313-cp313-win_amd64.whl

Download URL dately-3.3.0-cp313-cp313-win_amd64.whl
Size 415.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
86d27d3f278bad967bc389f7d31acd578a0ca5524cdfa14823b27b77a251ba95
BLAKE2b-256 checksum
How to use checksums
f237900107b2bef985c290a785fdf5606e4463870307cc79e9e4663fc192b11f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dately-3.3.0-cp312-cp312-win_amd64.whl

Download URL dately-3.3.0-cp312-cp312-win_amd64.whl
Size 417.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6674f39539c6fbe13b420482d064de303ae92124ad00cae902e0d2459b8105f2
BLAKE2b-256 checksum
How to use checksums
f52cc25733e0a2673c9dd0b5fee07245b2e777ccc8924b00421635363116345c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dately-3.3.0-cp311-cp311-win_amd64.whl

Download URL dately-3.3.0-cp311-cp311-win_amd64.whl
Size 417.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
593f842035da58ba1e09327c31e519225009fb51164907172b4de4dc50cd4c3a
BLAKE2b-256 checksum
How to use checksums
4e2a66eb317a8a7f011141fdb8b4f793a0b2ba0803ab6c760a3e590b1af8423f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dately-3.3.0-cp310-cp310-win_amd64.whl

Download URL dately-3.3.0-cp310-cp310-win_amd64.whl
Size 419.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
4ff43642345645ca06fb121e24f6a4ae119c14199587d81f90f6aa45c48d59bb
BLAKE2b-256 checksum
How to use checksums
0a8ca81b8c3c8261865fcab5fa4f4becf6f65bfafea188baa4c8d7f7b6b9ae9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dately-3.3.0-cp39-cp39-win_amd64.whl

Download URL dately-3.3.0-cp39-cp39-win_amd64.whl
Size 420.8 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
32f66177e9adfc2b3ec41623fdaba72dde717f8f2a122b9b4dd2e42c03cca94a
BLAKE2b-256 checksum
How to use checksums
96a84d7ab1a0f6c35ac9307953a672b4658e227ba609839ef264195bbe1d095a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dately-3.3.0-cp38-cp38-win_amd64.whl

Download URL dately-3.3.0-cp38-cp38-win_amd64.whl
Size 424.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
974c86c4caba2cc5b58a4f85f1c0d2e7d62ed1ee9a75c74da217b60ed715d30c
BLAKE2b-256 checksum
How to use checksums
92d0ff8b05d02efcb8b31b2552d5b8e0b9f6ae160eb7b8d76d84752f9d2459d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

3.3.1

8 release files

This release

3.3.0 This release

8 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.0.2

2 release files

3.0.1

2 release files

2.4.0

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.0.4

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page