Period¶
A calendar interval: months + days + nanoseconds.
Per T7, Period carries intraday units (nanoseconds) so a single type covers "every 1 month" and "every 90 minutes" alike. Application to a date or zoned date-time goes through an OverflowPolicy.
Two Periods are equal when all three components match. Periods do NOT support compare/lt/gt — "1 month vs 30 days" has no answer without a date to apply both against, so semantic ordering is intentionally absent. Apply both to a date and compare the results if you need it.
Constructors¶
create¶
Parameters¶
Returns¶
- Period val^
zero¶
The zero period: every component is zero.
Returns¶
- Period val^
of_months¶
Parameters¶
- m: I32 val
Returns¶
- Period val^
of_days¶
Parameters¶
- d: I32 val
Returns¶
- Period val^
of_hours¶
Parameters¶
- h: I64 val
Returns¶
- Period val^
of_minutes¶
Parameters¶
- m: I64 val
Returns¶
- Period val^
of_seconds¶
Parameters¶
- s: I64 val
Returns¶
- Period val^
of_nanos¶
Parameters¶
- n: I64 val
Returns¶
- Period val^
Public Functions¶
months¶
Returns¶
- I32 val
days¶
Returns¶
- I32 val
nanos¶
Returns¶
- I64 val
is_zero¶
True if every component is zero.
Returns¶
- Bool val
eq¶
Parameters¶
- other: Period val
Returns¶
- Bool val
ne¶
Parameters¶
- other: Period val
Returns¶
- Bool val
neg¶
Return -this: every component negated.
Returns¶
- Period val
add¶
Component-wise addition. Overflow wraps (Pony default +).
Parameters¶
- other: Period val
Returns¶
- Period val
sub¶
Component-wise subtraction.
Parameters¶
- other: Period val
Returns¶
- Period val
mul¶
Multiply every component by scalar n. Overflow wraps.
Parameters¶
- n: I32 val
Returns¶
- Period val
string¶
Debug-style representation: "Period(months=N, days=N, nanos=N)". Not ISO 8601 Duration format — that's a TODO; the negative-with- fractional-seconds case is fiddly enough to want its own design pass.
Returns¶
- String iso^