Verdandi Moment
Represents a specific instant in time with optional timezone context.
A VerdandiMoment wraps a Unix epoch (milliseconds since 1970-01-01T00:00:00Z) and exposes rich operations for adjustment, formatting, comparison, and timezone conversion. Instances are created through the Verdandi entry point.
Timezone awareness
By default a moment uses the device timezone. Use inTimeZone to project the same instant into a different timezone — the epoch stays identical, but component values (hour, day, offset, etc.) reflect the target zone:
val utc = Verdandi.from("2025-06-15T12:00:00Z")
val tokyo = utc inTimeZone VerdandiTimeZone.of("Asia/Tokyo")
tokyo.component.hour // 21
utc.inMilliseconds == tokyo.inMilliseconds // trueAdjustments
The adjust DSL allows natural-language date arithmetic:
val tomorrow = moment adjust { add one day }
val startOfDay = moment adjust { at startOf day }
val shifted = moment adjust { add three hours }Formatting
val iso = moment format { iso.date } // "2025-06-15"
val text = moment format "dd/MM/yyyy HH:mm" // "15/06/2025 14:30"Equality and comparison
Two moments are equal when they represent the same instant (same epoch), regardless of timezone context. compareTo also uses epoch-only ordering.
Properties
Functions
Adjusts this moment using the Verdandi DSL.
Computes the calendar-aware duration between this moment and other.
Formats this moment using the chain-based DSL.
Formats this moment using a pattern string.
Projects this instant into the given timeZone.
Returns true if this moment is strictly after other.
Returns true if this moment is strictly before other.
Returns true if this moment falls within interval (start-inclusive, end-exclusive).
Returns true if this moment falls within [start, end).
Returns true if this moment and other fall on the same calendar day in their respective timezone contexts.
Returns true if this moment and other fall in the same calendar month in their respective timezone contexts.
Returns true if this moment and other fall in the same calendar year in their respective timezone contexts.
Returns true if this moment falls on tomorrow's calendar date.
Creates a VerdandiInterval from this moment to other.
Computes the relative description of this moment compared to other.
Computes the relative description of this moment compared to Verdandi.now.
Returns true if this moment falls on yesterday's calendar date.