aeat.core.parsing._dates module

Date string parsers for the two distinct input formats used across AEAT adapters.

Provides a unified _parse_date() helper that combines format selection with an error-policy axis.

The two variants are intentionally separate because they accept different wire formats:

  • _parse_iso8601_date()YYYY-MM-DD (ISO 8601). Used wherever AEAT systems or profile storage serialises dates in the standard form (e.g. deadline-profile censo dates).

  • _parse_ddmmyyyy_date()DD-MM-YYYY or DD/MM/YYYY (day-first, separator is - or /). Used wherever the AEAT G313 (Mis Datos Censales) HTML page publishes dates in the Spanish day-first convention.

Both functions live at the core layer: they carry no domain dependencies, perform no I/O, and raise ValueError so callers can wrap the error in the domain-appropriate exception type.

parse_date(raw, *, fmt='iso8601', on_error='raise')

Public alias — cross-package callers must import parse_date rather than the private _parse_date implementation name.

Return type:

date | None

Parameters:
  • raw (str | None)

  • fmt (Literal['iso8601', 'ddmmyyyy'])

  • on_error (Literal['raise', 'none'])