RelativeDateAbsoluteTimeLocalizer

class RelativeDateAbsoluteTimeLocalizer(options: RelativeDateAbsoluteTimeOptions = RelativeDateAbsoluteTimeOptions(), locale: PlatformLocale = getDefaultLocale()) : PolyglotReferenceValueLocalizer<LocalDateTime> (source)

Localizes the date part of a LocalDateTime relative to a Zoned<Instant> reference point, and the time part absolutely.

This is mostly glue between RelativeLocalDateLocalizer and LocalTimeLocalizer. See their documentation to understand RelativeDateAbsoluteTimeOptions.dateOptions and RelativeDateAbsoluteTimeOptions.timeOptions.

Create once and re-use for localizing multiple values with the same options. Use LocalDateTime.localizeRelativeDateAbsoluteTime or LocalDateTime.localizeRelativeDateAbsoluteTimeAsFlow for one-off localizations.

Examples:

  • yesterday at 9:00 PM

  • next Sunday at 4:00 AM

  • in 15 days, 3:00 AM

  • 21 days ago at 7:00 PM

Constructors

Link copied to clipboard
constructor(options: RelativeDateAbsoluteTimeOptions = RelativeDateAbsoluteTimeOptions(), locale: PlatformLocale = getDefaultLocale())

Functions

Link copied to clipboard
open override fun localize(value: LocalDateTime, reference: Zoned<Instant>): TickingValue<String>
Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localize(value: T, clock: Clock = Clock.System): TickingValue<String>

Localizes value by using the given clock's Clock.now as a reference point, rather than passing the reference explicitly.

Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localizeAsFlow(value: T, clock: Clock = Clock.System, maxTick: Duration? = null): Flow<String>

Localizes value by using the given clock's Clock.now as a reference point and returns a Flow that emits updated values based on the underlying TickingValue.nextTick. This function assumes that the given clock moves forward linearly.