arelle.oim.tc.xs_dates

See COPYRIGHT.md for copyright information.

XML Schema date, dateTime, gYear and gYearMonth values with any year, the recurring time, gMonthDay, gDay and gMonth values as positions in their cycle in UTC, and yearMonth and dayTime durations.

Arelle models limit years to the datetime range. Table constraints can be validated without populating a model, so these types are parsed here without that limit.

Module Contents

Classes

XsInstant

A point on the XML Schema timeline as days from 1970-01-01 plus seconds into the day, normalised to UTC when a time zone is present.

Functions

days_since_epoch

Days from 1970-01-01 to the given Gregorian date, for any integer year.

year_number

The year on the timeline for an XML Schema year.

parse_date

parse_date_time

parse_g_year

parse_g_year_month

parse_time

Seconds into the day in UTC, so lexical variants of one time compare equal.

parse_g_month_day

parse_g_day

parse_g_month

parse_year_month_duration

The length in months of a duration with only year and month parts.

parse_day_time_duration

The length in seconds of a duration with only day and time parts.

API

class arelle.oim.tc.xs_dates.XsInstant

A point on the XML Schema timeline as days from 1970-01-01 plus seconds into the day, normalised to UTC when a time zone is present.

day: int

None

second: decimal.Decimal

None

zoned: bool

None

compare(other: arelle.oim.tc.xs_dates.XsInstant) → int | None

Returns -1, 0 or 1 ordering self against other, or None when the order is indeterminate because exactly one of the two carries a time zone.

arelle.oim.tc.xs_dates.days_since_epoch(year: int, month: int, day: int) → int

Days from 1970-01-01 to the given Gregorian date, for any integer year.

This is Howard Hinnant’s days_from_civil algorithm.

arelle.oim.tc.xs_dates.year_number(lexical_year: str) → int

The year on the timeline for an XML Schema year.

arelle.oim.tc.xs_dates.parse_date(value: str) → arelle.oim.tc.xs_dates.XsInstant | None
arelle.oim.tc.xs_dates.parse_date_time(value: str) → arelle.oim.tc.xs_dates.XsInstant | None
arelle.oim.tc.xs_dates.parse_g_year(value: str) → arelle.oim.tc.xs_dates.XsInstant | None
arelle.oim.tc.xs_dates.parse_g_year_month(value: str) → arelle.oim.tc.xs_dates.XsInstant | None
arelle.oim.tc.xs_dates.parse_time(value: str) → decimal.Decimal | None

Seconds into the day in UTC, so lexical variants of one time compare equal.

arelle.oim.tc.xs_dates.parse_g_month_day(value: str) → decimal.Decimal | None
arelle.oim.tc.xs_dates.parse_g_day(value: str) → decimal.Decimal | None
arelle.oim.tc.xs_dates.parse_g_month(value: str) → decimal.Decimal | None
arelle.oim.tc.xs_dates.parse_year_month_duration(value: str) → decimal.Decimal | None

The length in months of a duration with only year and month parts.

arelle.oim.tc.xs_dates.parse_day_time_duration(value: str) → decimal.Decimal | None

The length in seconds of a duration with only day and time parts.