TickingDurationLocalizer

class TickingDurationLocalizer(options: TickingDurationOptions = TickingDurationOptions(), locale: PlatformLocale = getDefaultLocale()) : PolyglotValueLocalizer<Duration, TickingValue<String>> (source)

Localizes a Duration in the same exact way as a DurationLocalizer, but this is meant to be used to localize duration values that change over time (e.g. a countdown). For static durations use DurationLocalizer instead.

The TickingValue.value will be the same as the output of Duration.localize.

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.

Create once and re-use for localizing multiple values with the same options. Use Duration.localizeTicking for one-off localizations.

Examples:

  • 1h 5m

  • 1 hr, 5 min

  • 1 hour, 5 minutes

Constructors

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

Functions

Link copied to clipboard
open override fun localize(value: Duration): TickingValue<String>