VerdandiRelativeMoment

@Serializable
sealed interface VerdandiRelativeMoment

Represents the result of comparing two VerdandiMoment instances, expressing their temporal distance as a human-readable relative description.

A VerdandiRelativeMoment is one of three cases:

  • Now — the two moments are identical (zero distance).

  • Past — the reference moment is before the target moment.

  • Future — the reference moment is after the target moment.

Use format to produce a localized string from the relative moment:

val relative: VerdandiRelativeMoment = momentA.relative(momentB)

val text = relative format {
onNow { "just now" }
onPast { diff -> "$diff ago" }
onFuture { diff -> "in $diff" }
}

See also

Inheritors

Functions

Link copied to clipboard
open infix fun format(block: VerdandiRelativeFormatScope.() -> Unit): String

Formats this relative moment into a human-readable string using the given DSL block.