Skip to content

Initializer

init(allowedUnits:width:maximumUnitCount:zeroValueUnits:valueLengthLimits:fractionalPart:)

iOS 16.0+ iPadOS 16.0+ Mac Catalyst 16.0+ macOS 13.0+ tvOS 16.0+ watchOS 9.0+
Creates an instance using the provided specifications.
init<ValueRange>(allowedUnits: Set<Duration.UnitsFormatStyle.Unit>, width: Duration.UnitsFormatStyle.UnitWidth, maximumUnitCount: Int? = nil, zeroValueUnits: Duration.UnitsFormatStyle.ZeroValueUnitsDisplayStrategy = .hide, valueLengthLimits: ValueRange, fractionalPart: Duration.UnitsFormatStyle.FractionalPartDisplayStrategy = .hide) where ValueRange : RangeExpression, ValueRange.Bound == Int

Parameters

allowedUnits

The units that may be included in the output string.

width

The width of the unit and the spacing between the value and the unit.

maximumUnitCount

The maximum number of time units to include in the output string.

zeroValueUnits

The strategy for how zero-value units are handled.

valueLengthLimits

The padding or truncating behavior of the unit value. Values with negative bounds are ignored.

fractionalPart

The strategy for displaying a duration if it cannot be represented exactly with the allowed units.