RelativeDurationLocalizer

Localizes a single Duration unit (usually the biggest one) in a relative way.

The localize function returns a TickingValue value indicating when a new localize call is required to update the value.

For the purposes of TickingValue.nextTick, this class assumes that the given Duration is obtained from a computation that linearly "moves" backwards, i.e. a positive duration means something that will happen in the future, and a negative duration something that has happened in the past. For instance, if given the duration 10 seconds, this class assumes that in 1.5 seconds the Duration would be 8.5 seconds.

The output string will contain the correct localized words for "in" and "ago". If you just need the "next tick" behavior but do not want the relative localization, you can use TickingDurationLocalizer instead.

Examples:

  • 10 minutes ago

  • in 1 hour

  • 4h ago

  • 4 hr. ago

  • in 2 days

actual class RelativeDurationLocalizer : PolyglotValueLocalizer<ERROR CLASS: Symbol not found for Duration, TickingValue<String>> (source)

Localizes a single Duration unit (usually the biggest one) in a relative way.

The localize function returns a TickingValue value indicating when a new localize call is required to update the value.

For the purposes of TickingValue.nextTick, this class assumes that the given Duration is obtained from a computation that linearly "moves" backwards, i.e. a positive duration means something that will happen in the future, and a negative duration something that has happened in the past. For instance, if given the duration 10 seconds, this class assumes that in 1.5 seconds the Duration would be 8.5 seconds.

The output string will contain the correct localized words for "in" and "ago". If you just need the "next tick" behavior but do not want the relative localization, you can use TickingDurationLocalizer instead.

Examples:

  • 10 minutes ago

  • in 1 hour

  • 4h ago

  • 4 hr. ago

  • in 2 days

Localizes a single Duration unit (usually the biggest one) in a relative way.

The localize function returns a TickingValue value indicating when a new localize call is required to update the value.

For the purposes of TickingValue.nextTick, this class assumes that the given Duration is obtained from a computation that linearly "moves" backwards, i.e. a positive duration means something that will happen in the future, and a negative duration something that has happened in the past. For instance, if given the duration 10 seconds, this class assumes that in 1.5 seconds the Duration would be 8.5 seconds.

The output string will contain the correct localized words for "in" and "ago". If you just need the "next tick" behavior but do not want the relative localization, you can use TickingDurationLocalizer instead.

Examples:

  • 10 minutes ago

  • in 1 hour

  • 4h ago

  • 4 hr. ago

  • in 2 days

Constructors

Link copied to clipboard
expect constructor(options: RelativeDurationOptions = RelativeDurationOptions(), locale: PlatformLocale = getDefaultLocale())
actual constructor(options: RelativeDurationOptions, locale: PlatformLocale)
actual constructor(options: RelativeDurationOptions, locale: PlatformLocale)

Functions

Link copied to clipboard
expect open override fun localize(value: Duration): TickingValue<String>
abstract fun localize(value: ERROR CLASS: Symbol not found for Duration): TickingValue<String>
actual open override fun localize(value: ERROR CLASS: Symbol not found for Duration): TickingValue<String>
actual open override fun localize(value: Duration): TickingValue<String>