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.1

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.1
File Size Uploaded
dately-3.3.1.tar.gz 2.0 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for dately 3.3.1
File
dately-3.3.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
dately-3.3.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
dately-3.3.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
dately-3.3.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
dately-3.3.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
dately-3.3.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
dately-3.3.1-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.1.tar.gz

Download URL dately-3.3.1.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
84cebac40d63c24854771e42e2c6688b8d76794337035df98922120ddf7c0e32
BLAKE2b-256 checksum
How to use checksums
68dfb3d421d76a78f26fb86e5dbaa58a873510ffdc5c8f47fd95603070195f99
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.1-cp314-cp314-win_amd64.whl

Download URL dately-3.3.1-cp314-cp314-win_amd64.whl
Size 422.4 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
9d63bf7413d7a5294df0e6d12ff30b649238f15034b02c60b285f04b80d8fec3
BLAKE2b-256 checksum
How to use checksums
bfe2db7dbe5e87455b41498dbf162ab753ed15c5f9e832108187bed829d6f0b2
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.1-cp313-cp313-win_amd64.whl

Download URL dately-3.3.1-cp313-cp313-win_amd64.whl
Size 415.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
9b20ed6df266c4876ec4927e4c17858a6e568ca97fe58642731f4b828385cc09
BLAKE2b-256 checksum
How to use checksums
50fa3d9324a3b633e721e09935b57eef5a842fac44d02b210f7ed1cb5113b981
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.1-cp312-cp312-win_amd64.whl

Download URL dately-3.3.1-cp312-cp312-win_amd64.whl
Size 417.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
0cc0defea5812260faea51e00381c6103b2bd9c1f3d23267fe81b55e08fe6060
BLAKE2b-256 checksum
How to use checksums
00a893f2ab5205a34b8f9d2ce756d89f651361f178102dff06ba2f8b7809d948
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.1-cp311-cp311-win_amd64.whl

Download URL dately-3.3.1-cp311-cp311-win_amd64.whl
Size 417.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c78bdcbdba6cbf360ed2bbbaa4431d0034cf6da930b418d0b0ac77f4ffadcf31
BLAKE2b-256 checksum
How to use checksums
0cd3fbed11f45266e07254f6768347b5b401786037714449d035ca94e58dd46d
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.1-cp310-cp310-win_amd64.whl

Download URL dately-3.3.1-cp310-cp310-win_amd64.whl
Size 419.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
3917268bd41617469d4662306580ce2c5c602bf4a9a7b434934dbf9ebd42bef0
BLAKE2b-256 checksum
How to use checksums
076f6c0ccc779bd8539dfc919e8f17083b28d213958f23886e777a727a79fb10
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.1-cp39-cp39-win_amd64.whl

Download URL dately-3.3.1-cp39-cp39-win_amd64.whl
Size 420.8 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
e50ab39a539bfe139725b7edc45c364e7474ee5fa5b22f372c05672cf0120303
BLAKE2b-256 checksum
How to use checksums
e8ecfa187d9c4e4e8a8ecc843279ec30f12ae4ea0fe00bd7d6a3996181350559
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.1-cp38-cp38-win_amd64.whl

Download URL dately-3.3.1-cp38-cp38-win_amd64.whl
Size 424.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
b550efeb451859ea590071090041a17fe90abd4feef52e2bf13d0351e6b7c772
BLAKE2b-256 checksum
How to use checksums
eff57652e611d5070ad58fd9079585d11379105c8093d5eb391c22f84f34b83f
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

This release

3.3.1 This release

8 release files

3.3.0

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