init(allowedUnits:width:maximumUnitCount:zeroValueUnits:valueLengthLimits:fractionalPart:)
Creates a units format style using the given parameters.
Declaration
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 == IntParameters
- allowedUnits:
The units that the formatted string may include.
- width:
The width of the unit and the spacing between the value and the unit.
- maximumUnitCount:
The maximum number of duration units to include in the output string.
- zeroValueUnits:
The strategy for handling leading units with zero values.
- valueLengthLimits:
The padding or truncating behavior of the unit value, as a bounded range of
Intvalues. - fractionalPart:
The strategy for displaying a duration if a formatted string can’t represent it exactly with the allowed units.
Discussion
Use this convenience function in situations that expect a Duration.UnitsFormatStyle, such as formatted(_:), as an alternative to using the full initializer.