Version: latest (v0.3.0)

calendar_period

Stable type · Other

Tier: stable · Kind: type · Topic: Other

PythonJuliaRust
CalendarPeriodCalendarPeriodCalendarPeriod

Python

class CalendarPeriod
CalendarPeriod(months: int = 0, seconds: int = 0)
@classmethod CalendarPeriod.parse(iso: str) -> CalendarPeriod
@classmethod CalendarPeriod.of(value: CalendarPeriod | _dt.timedelta | str | int) -> CalendarPeriod
CalendarPeriod.approximate_seconds() -> float
CalendarPeriod.anchor(start: _dt.datetime, k: int) -> _dt.datetime
CalendarPeriod.floor(start: _dt.datetime, t: _dt.datetime) -> int
CalendarPeriod.ceil(start: _dt.datetime, t: _dt.datetime) -> int

A cadence step of months calendar months plus seconds seconds.

Members

  • parse — Read P[nY][nM][nW][nD][T[nH][nM][nS]] (spec §2.1).
  • of — A period from a period, a fixed timedelta, an ISO string or whole seconds.
  • approximate_seconds — A mean length, only for estimating an anchor index (never an anchor).
  • anchor — add_months(start, k*months) + k*seconds.
  • floor — The largest k with anchor(start, k) <= t.
  • ceil — The smallest k with anchor(start, k) >= t.

Source

Julia

struct CalendarPeriod
CalendarPeriod(months::Integer, seconds::Integer)
CalendarPeriod(iso::AbstractString)
CalendarPeriod(p::Union{Dates.Month, Dates.Year})
CalendarPeriod(p::Union{Dates.Day, Dates.Hour, Dates.Minute, Dates.Second, Dates.Week})
CalendarPeriod(p::CalendarPeriod)
CalendarPeriod(months, seconds)
CalendarPeriod(iso::AbstractString)
CalendarPeriod(p::Dates.Period)

A cadence step of months calendar months plus seconds seconds (spec/esm-sources.md §2.1). From an ISO 8601 string ("P1M", "PT3H"), or from a Dates period (Month(1), Hour(3)).

Source

Rust

pub struct CalendarPeriod {
    pub months: i64,
    pub seconds: i64,
}

impl CalendarPeriod { pub fn months(months: i64) -> Self }

impl CalendarPeriod { pub fn seconds(seconds: i64) -> Self }

impl CalendarPeriod { pub fn parse(iso: &str) -> Result<Self> }

impl CalendarPeriod { pub fn is_positive(&self) -> bool }

impl CalendarPeriod { pub fn anchor(&self, start: OffsetDateTime, k: i64) -> OffsetDateTime }

impl CalendarPeriod { pub fn floor_index(&self, start: OffsetDateTime, t: OffsetDateTime) -> i64 }

impl CalendarPeriod { pub fn ceil_index(&self, start: OffsetDateTime, t: OffsetDateTime) -> i64 }

impl CalendarPeriod { pub fn floor(&self, start: OffsetDateTime, t: OffsetDateTime) -> OffsetDateTime }

A cadence step of whole calendar months plus whole seconds (spec/esm-sources.md §2.1): P1M is one month, P1Y twelve, PT3H 10800 seconds, P1D 86400 seconds (a UTC day).

Source · Rust docs