betty.date module

Localize dates.

class betty.date.Date[source]

Bases: LinkedDataDumpableJsonLdObject

A (Gregorian) date.

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

If this date is comparable to other dateys.

property complete: bool

Whether this date is complete.

day: int | None
async dump_linked_data(project: Project, context_definition: str | None = None) DumpMapping[Dump][source]

Dump this instance to JSON-LD.

fuzzy: bool
async classmethod linked_data_schema(project: Project) DateSchema[source]

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[source]

Convert this date to a date range.

year: int | None
class betty.date.DateRange[source]

Bases: LinkedDataDumpableJsonLdObject

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)[source]
property comparable: bool

If this date is comparable to other dateys.

async dump_linked_data(project: Project, start_context_definition: str | None = None, end_context_definition: str | None = None) DumpMapping[Dump][source]

Dump this instance to JSON-LD.

end: Date | None
end_is_boundary: bool
async classmethod linked_data_schema(project: Project) DateRangeSchema[source]

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

start: Date | None
start_is_boundary: bool
final class betty.date.DateRangeSchema[source]

Bases: JsonLdObject

A JSON Schema for betty.date.DateRange.

__init__(json_ld_schema: JsonLdSchema, date_schema: DateSchema)[source]
async classmethod new() Self[source]

Create a new instance.

final class betty.date.DateSchema[source]

Bases: JsonLdObject

A JSON Schema for betty.date.Date.

__init__(json_ld_schema: JsonLdSchema)[source]
async classmethod new() Self[source]

Create a new instance.

class betty.date.DateySchema[source]

Bases: OneOf

A JSON Schema for betty.date.Datey.

__init__(date_schema: DateSchema, date_range_schema: DateRangeSchema)[source]
async classmethod new() Self[source]

Create a new instance.

exception betty.date.IncompleteDateError[source]

Bases: ValueError

Raised when a datey was unexpectedly incomplete.