VerdandiMoment

@Serializable
data class VerdandiMoment : Comparable<VerdandiMoment>

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 // true

Adjustments

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

Link copied to clipboard

Decomposed date/time components (year, month, day, hour, minute, second, millisecond, UTC offset) resolved in this moment's timezone context.

Link copied to clipboard

The Unix epoch in milliseconds since 1970-01-01T00:00:00Z.

Functions

Link copied to clipboard

Adjusts this moment using the Verdandi DSL.

Link copied to clipboard
open operator override fun compareTo(other: VerdandiMoment): Int
operator fun compareTo(milliseconds: Long): Int
Link copied to clipboard

Computes the calendar-aware duration between this moment and other.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Formats this moment using the chain-based DSL.

infix fun format(pattern: String): String

Formats this moment using a pattern string.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Projects this instant into the given timeZone.

Link copied to clipboard
infix fun isAfter(other: VerdandiMoment): Boolean

Returns true if this moment is strictly after other.

Link copied to clipboard
infix fun isBefore(other: VerdandiMoment): Boolean

Returns true if this moment is strictly before other.

Link copied to clipboard

Returns true if this moment falls within interval (start-inclusive, end-exclusive).

Returns true if this moment falls within [start, end).

Link copied to clipboard

Returns true if this moment and other fall on the same calendar day in their respective timezone contexts.

Link copied to clipboard

Returns true if this moment and other fall in the same calendar month in their respective timezone contexts.

Link copied to clipboard

Returns true if this moment and other fall in the same calendar year in their respective timezone contexts.

Link copied to clipboard

Returns true if this moment falls on today's calendar date.

Link copied to clipboard

Returns true if this moment falls on tomorrow's calendar date.

Link copied to clipboard

Returns true if this moment falls on a weekday (Monday–Friday).

Link copied to clipboard

Returns true if this moment falls on a Saturday or Sunday.

Link copied to clipboard
operator fun minus(dateDuration: DateDuration): VerdandiMoment
operator fun minus(dateTimeDuration: DateTimeDuration): VerdandiMoment
operator fun minus(duration: Duration): VerdandiMoment
Link copied to clipboard
operator fun plus(dateDuration: DateDuration): VerdandiMoment
operator fun plus(dateTimeDuration: DateTimeDuration): VerdandiMoment
operator fun plus(duration: Duration): VerdandiMoment
Link copied to clipboard

Creates a VerdandiInterval from this moment to other.

Link copied to clipboard
fun relativeTo(other: VerdandiMoment, nowThreshold: Duration = 59.seconds): VerdandiRelativeMoment

Computes the relative description of this moment compared to other.

Link copied to clipboard
fun relativeToNow(nowThreshold: Duration = 59.seconds): VerdandiRelativeMoment

Computes the relative description of this moment compared to Verdandi.now.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun VerdandiMoment.toNSDate(): NSDate
Link copied to clipboard
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
Link copied to clipboard

Returns true if this moment falls on yesterday's calendar date.