Skip to main content

Github CI

Citation Date Parser

citation-date is a Python library for parsing and normalizing dates from Philippine legal citations, including dockets, reports, and other references. It handles common typos and multiple date formats with US and UK variants. It is eventually used by the dataset employed in LawSQL.

It is deliberately corpus-driven: the grammar preserves observed formatting damage in Supreme Court citation material without trying to guess unrecorded OCR spellings.

Upgrading from 0.2.1? Read the 1.0 release notes for the behavior changes and before/after examples.

Purpose

The library is designed to:

  • Extract dates from text commonly found in legal documents such as Philippine Supreme Court reports (SCRA) and dockets (G.R. No. ...).
  • Handle both US (Month Day, Year) and UK (Day Month Year) date formats.
  • Normalize dates to standard formats (%B %d, %Y or datetime.date).
  • Support dates enclosed in parentheses () or brackets [], and in raw strings.
  • Provide regex patterns and utility functions for downstream processing in other citation libraries.

Key Components

Regex Patterns

US/UK Date Patterns

from citation_date import uk_pattern, us_pattern

assert us_pattern.search("Dec. 1, 2000")
assert uk_pattern.search("1Dec. 2000")

These patterns detect date candidates with compact forms, ordinary punctuation, and the documented duplicate-comma UK variant. They do not match inside a larger alphanumeric token.

Report Dates

  • REPORT_DATE_REGEX matches dates in citations like 1 SCRA 200 (1Dec. 2000).
  • Supports naked dates, bracketed [Dec. 1, 2000], or parenthesis (Dec. 1, 2000).

Docket Dates

  • DOCKET_DATE_REGEX matches docket-specific dates such as G.R. No. 12345, Dec,1, 2000.
  • DOCKET_DATE_FORMAT standardizes formatting to %b. %d, %Y.

Decoding behavior

decode_date() returns the first calendar-valid full date in the text as %B %d, %Y, or as datetime.date when is_output_date_object=True. Unsupported syntax, impossible calendar dates, and year-only report values return None. Compile raw regex constants with re.I | re.X.

Documentation

See the documentation for the regex contracts, decoder reference, and usage paths.

Metadata

Release files for citation-date 1.0.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 citation-date 1.0.1
File Size Uploaded Provenance Actions
citation_date-1.0.1.tar.gz 5.8 kB Without provenance Details for citation_date-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for citation-date 1.0.1
File Interpreter ABI Platform Actions
citation_date-1.0.1-py3-none-any.whl Python 3 none any Details for citation_date-1.0.1-py3-none-any.whl

Total release size: 14.0 kB

Release files / citation_date-1.0.1.tar.gz

Download URL citation_date-1.0.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9c74b99c3e3648c92b405de24a49d41fabcd0d6397da55888658020cb3d0f95c
BLAKE2b-256 checksum
How to use checksums
f17998a8ba36a0feb096923b427599f87845916aa3ee6825461b756a4c57eb72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / citation_date-1.0.1-py3-none-any.whl

Download URL citation_date-1.0.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eea2be7d8bd54039586a2bcc368bf87fd380bd4b13248fbc9936a155eea2d1fc
BLAKE2b-256 checksum
How to use checksums
007b1a20436a74b6f2d00c41f7ddbbbed295b15d4d2b5f4ecc1685047471e734
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for citation-date 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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