prefixdate
Parse and process date string of varied precision as prefixes in Python.
What it is and what it does
Prefixdate is a lightweight date parser for handling dates where only partial information is known—a year alone, a year and month, or a full date. It normalizes these partial dates into a consistent format and tracks the precision level (year, month, day, or finer) so your application knows what was actually specified. The library accepts strings in ISO 8601-like format (e.g., '2001', '2001-4', '2001-04-02'), integers, datetime objects, or custom format strings via strptime patterns, and returns a structured DatePrefix object with both the normalized text representation and precision metadata.
The package is designed for contexts where sources report dates with varying completeness—common in historical records, metadata, or user-supplied information. It does not implement the full complexity of ISO 8601 or RFC 3339 (no date ranges, no week notation), focusing instead on the practical case of partial dates. It has no external dependencies and runs on Python 3.11 and newer.
Use it for:
- Normalize dates from historical datasets where only year or year-month is known, preserving precision information.
- Parse user-supplied dates in custom formats and standardize them to ISO 8601-like strings for storage.
- Validate and re-format partial dates in metadata systems that track date confidence.
- Handle datetime objects with custom precision truncation (e.g., round to minute or hour level).
- Accept dates in multiple formats and produce consistent normalized output.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses date strings with partial precision (year, month, or day) into a structured format, normalizing and validating them for use in applications that handle incomplete date information.
Yes. Prefixdate solves a specific, real problem—handling dates with incomplete precision—cleanly and with zero dependencies. It is actively maintained, licensed permissively, supports current Python versions, and has no known vulnerabilities. Install it if your application needs to parse or normalize dates where only partial information is available; skip it if you only work with complete dates.
Install
prefixdate on PyPI
pip
pip install prefixdateuv
uv add prefixdatepoetry
poetry add prefixdateInstalling prefixdate
Before you install
Installs cleanly with no runtime dependencies. Actively maintained with a recent release; last commit was 2026-08-08 and the project is not archived.
License in practice
MIT license permits use, modification, and distribution with minimal restrictions, making it suitable for both open and proprietary projects.
Quickstart
pip install prefixdate
from prefixdate import parse, normalize_date, Precision
date = parse('2001-3')
print(date.text) # '2001-03'
print(date.precision) # Precision.MONTH
normalized = normalize_date('2001-1')
print(normalized) # '2001-01'
Requires Python 3.11 or newer.
Verify before relying
- Whether the library handles leap-year edge cases or other calendar complexities beyond what the caveats mention.
- Performance characteristics when parsing large batches of dates or with many custom format strings.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 914,009/month — #4,736 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: prefixdate-0.6.1-py3-none-any.whl
Keywords: date, iso8601, partial date, rfc3339
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
iso8601Parses ISO 8601 date strings (e.g.…
permissive · top 5,000 on PyPI
dateparserParses dates from text in multiple languages…
permissive · top 1,000 on PyPI
isodateParses and formats ISO 8601 date, time,…
permissive · top 1,000 on PyPI
dateformatParses strings into datetime objects and…
permissive · top 15,000 on PyPI
arrowArrow provides a simpler, more intuitive API…
permissive · top 1,000 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
aniso8601Parses ISO 8601 date, time, datetime, duration,…
permissive · top 5,000 on PyPI
metomi-isodatetimeParses and manipulates ISO 8601 date-time…
copyleft · top 15,000 on PyPI
tonyg-rfc3339Parses and formats RFC 3339 date-time strings…
unclear · top 15,000 on PyPI
rfc3339Formats and parses dates according to RFC 3339,…
unclear · top 5,000 on PyPI