skillfed

prefixdate

Parse and process date string of varied precision as prefixes in Python.

prefixdate v0.6.1 914.0K downloads/30d#4,736 on PyPI14
Permissive license MIT Active released

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 prefixdate

uv

uv add prefixdate

poetry

poetry add prefixdate

Installing 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

Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

partial date parsingincomplete date handlingdate precision normalizationiso8601 prefix datesflexible date parseryear-month-day parsing
date-parsingdata-normalization

More Text Processing packages