Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.locale.date module

Localize dates.

class betty.locale.date.Date

  Bases: `LinkedDataDumpable`

  A (Gregorian) date.

  __init__(year: int | None = None, month: int | None = None, day: int | None = None, fuzzy: bool = False)
  property comparable: bool

    If this date is comparable to other dateys.

  property complete: bool

    Whether this date is complete.

  async datey_dump_linked_data(dump: MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]], start_schema_org: str, end_schema_org: str) → None

    Dump this instance to JSON-LD for a ‘datey’ field.

  day: int | None
  async dump_linked_data(project: Project, schemas_org: list[str] | None = None) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  fuzzy: bool
  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  month: int | None
  property parts: tuple[int | None, int | None, int | None]

    The date parts: a 3-tuple of the year, month, and day.

  to_range() → DateRange

    Convert this date to a date range.

  year: int | None

class betty.locale.date.DateRange

  Bases: `LinkedDataDumpable`

  A date range can describe a period of time between, before, after, or around start and/or end dates.

  __init__(start: Date | None = None, end: Date | None = None, start_is_boundary: bool = False, end_is_boundary: bool = False)
  property comparable: bool

    If this date is comparable to other dateys.

  async datey_dump_linked_data(dump: MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]], start_schema_org: str, end_schema_org: str) → None

    Dump this instance to JSON-LD for a ‘datey’ field.

  async dump_linked_data(project: Project, start_schema_org: str | None = None, end_schema_org: str | None = None) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  end: Date | None
  end_is_boundary: bool
  async classmethod linked_data_schema(project: Project) → DumpMapping[Dump]

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  start: Date | None
  start_is_boundary: bool

exception betty.locale.date.IncompleteDateError

  Bases: `ValueError`

  Raised when a datey was unexpectedly incomplete.

async betty.locale.date.ref_date(root_schema: DumpMapping[Dump], project: Project) → DumpMapping[Dump]

  Reference the Date schema.

async betty.locale.date.ref_date_range(root_schema: DumpMapping[Dump], project: Project) → DumpMapping[Dump]

  Reference the DateRange schema.

async betty.locale.date.ref_datey(root_schema: DumpMapping[Dump], project: Project) → DumpMapping[Dump]

  Reference the Datey schema.