Skip to content

Period

[Source]

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.

class val Period

Constructors

create

[Source]

new val create(
  months': I32 val = 0,
  days': I32 val = 0,
  nanos': I64 val = 0)
: Period val^

Parameters

  • months': I32 val = 0
  • days': I32 val = 0
  • nanos': I64 val = 0

Returns


zero

[Source]

The zero period: every component is zero.

new val zero()
: Period val^

Returns


of_months

[Source]

new val of_months(
  m: I32 val)
: Period val^

Parameters

Returns


of_days

[Source]

new val of_days(
  d: I32 val)
: Period val^

Parameters

Returns


of_hours

[Source]

new val of_hours(
  h: I64 val)
: Period val^

Parameters

Returns


of_minutes

[Source]

new val of_minutes(
  m: I64 val)
: Period val^

Parameters

Returns


of_seconds

[Source]

new val of_seconds(
  s: I64 val)
: Period val^

Parameters

Returns


of_nanos

[Source]

new val of_nanos(
  n: I64 val)
: Period val^

Parameters

Returns


Public Functions

months

[Source]

fun val months()
: I32 val

Returns


days

[Source]

fun val days()
: I32 val

Returns


nanos

[Source]

fun val nanos()
: I64 val

Returns


is_zero

[Source]

True if every component is zero.

fun val is_zero()
: Bool val

Returns


eq

[Source]

fun val eq(
  other: Period val)
: Bool val

Parameters

Returns


ne

[Source]

fun val ne(
  other: Period val)
: Bool val

Parameters

Returns


neg

[Source]

Return -this: every component negated.

fun val neg()
: Period val

Returns


add

[Source]

Component-wise addition. Overflow wraps (Pony default +).

fun val add(
  other: Period val)
: Period val

Parameters

Returns


sub

[Source]

Component-wise subtraction.

fun val sub(
  other: Period val)
: Period val

Parameters

Returns


mul

[Source]

Multiply every component by scalar n. Overflow wraps.

fun val mul(
  n: I32 val)
: Period val

Parameters

Returns


string

[Source]

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.

fun val string()
: String iso^

Returns