Relative Year Localizer
class RelativeYearLocalizer(options: RelativeYearOptions = RelativeYearOptions(), locale: PlatformLocale = getDefaultLocale()) : PolyglotReferenceValueLocalizer<Int> (source)
Localizes a year relative to a Zoned<Instant> reference point.
As this class implements PolyglotReferenceValueLocalizer, it allows to use localizeAsFlow.
Localization could, based on options, prioritize a word style localization (e.g. last year) over a numeric style (e.g. 1 year ago).
Because kotlinx-datetime doesn't provide a standard type for a year, there is no extension function equivalent for one-off localizations.
Examples:
last yr.this yearnext year1 year agoin 5y
See also
Constructors
Link copied to clipboard
constructor(options: RelativeYearOptions = RelativeYearOptions(), locale: PlatformLocale = getDefaultLocale())
Functions
Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localizeAsFlow(value: T, clock: Clock = Clock.System, maxTick: Duration? = null): Flow<String>
Link copied to clipboard
Convenience function to format an already calculated diff of years (e.g. -1 for last year).