Contents

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

Creates a units format style using the given parameters.

Declaration

init(allowedUnits: Set<Duration.UnitsFormatStyle.Unit>, width: Duration.UnitsFormatStyle.UnitWidth, maximumUnitCount: Int? = nil, zeroValueUnits: Duration.UnitsFormatStyle.ZeroValueUnitsDisplayStrategy = .hide, valueLength: Int? = nil, fractionalPart: Duration.UnitsFormatStyle.FractionalPartDisplayStrategy = .hide)

Parameters

  • 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.

  • valueLength:

    The padding or truncating behavior of the unit value, as an Int.

  • 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.

See Also

Creating a units format style