DurationOptions

data class DurationOptions(val minUnit: DurationUnit = DurationUnit.SECONDS, val maxUnits: Int = 2, val omitZeros: Boolean = true, val style: DurationStyle = DurationStyle.WIDE, val ifZeroLocalization: (PlatformLocale) -> String? = { null })(source)

Localization options for DurationLocalizer and Duration.localize

Constructors

Link copied to clipboard
constructor(minUnit: DurationUnit = DurationUnit.SECONDS, maxUnits: Int = 2, omitZeros: Boolean = true, style: DurationStyle = DurationStyle.WIDE, ifZeroLocalization: (PlatformLocale) -> String? = { null })

Properties

Link copied to clipboard

string that will be returned as-is in case if all allowable units to display are zero. Note that this doesn't necessarily mean that the passed Duration is itself Duration.ZERO, but rather that it's smaller than the minUnit. If this is null, the default 0 <min-unit> localized string will be returned in this case.

Link copied to clipboard

maximum number of units that will be retuned. If the Duration spans more than maxUnits units (e.g. 3h 1m 3s), only the biggest maxUnits will be returned.

Link copied to clipboard

the smallest unit that will be in output. If the Duration is smaller, 0 <min-unit> will be returned (see also the ifZeroLocalization parameter)

Link copied to clipboard

whether to omit middle units that are zero. If a unit is omitted, the next non-zero smaller one will be returned (e.g. omitZero=false, maxUnits=2, output=3h 0m; omitZero=true, maxUnits=2, output=3h 3s)

Link copied to clipboard

the style of duration units, Also applies to the style of the list (in case there is more than one unit to show)