init(from:)
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
init(from decoder: any Decoder) throws
init(from decoder: any Decoder) throws
ss8DurationV30FoundationInternationalizationE16UnitsFormatStyleV4fromAEs7Decoder_p_tKcfc
What are these?9BVB4
import Swift
import FoundationInternationalization
struct UnitsFormatStyle
A FormatStyle
that displays a duration as a list of duration units, such as “2 hours, 43 minutes, 26 seconds” in English.
@frozen struct Duration
A representation of high precision time.
protocol Decoder
A type that can decode values from a native format into in-memory representations.
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)
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
Creates an instance using the provided specifications.
var allowedUnits: Set<Duration.UnitsFormatStyle.Unit>
The units that may be included in the output string.
var attributed: Duration.UnitsFormatStyle.Attributed { get }
Returns a Duration.UnitsFormatStyle.Attributed
style to format a duration as an attributed string using the configuration of this format style. Units in the string are annotated with the durationField
and measurement
attribute keys and the DurationFieldAttribute
and MeasurementAttribute
attribute values.
var fractionalPartDisplay: Duration.UnitsFormatStyle.FractionalPartDisplayStrategy
The strategy for displaying a duration if it cannot be represented exactly with the allowed units.
var locale: Locale
The locale to use when formatting the duration.
var maximumUnitCount: Int?
The maximum number of time units to include in the output string.
var unitWidth: Duration.UnitsFormatStyle.UnitWidth
The width of the unit and the spacing between the value and the unit.
var valueLengthLimits: Range<Int>?
The padding or truncating behavior of the unit value.
var zeroValueUnitsDisplay: Duration.UnitsFormatStyle.ZeroValueUnitsDisplayStrategy
The strategy for how zero-value units are handled.
func discreteInput(after input: Duration) -> Duration?
func discreteInput(before input: Duration) -> Duration?
func format(_ duration: Duration) -> String
Creates a locale-aware string representation from a duration value.
func locale(_ locale: Locale) -> Duration.UnitsFormatStyle
A modifier to set the locale of the format style.
@dynamicMemberLookup struct Attributed
A format style to format a duration as an attributed string. Units in the string are annotated with the durationField
and measurement
attribute keys and the DurationFieldAttribute
and MeasurementAttribute
attribute values.
struct FractionalPartDisplayStrategy
Specifies how a duration is displayed if it cannot be represented exactly with the allowed units.
struct Unit
Units that a duration can be displayed as with UnitsFormatStyle
.
struct UnitWidth
Specifies the width of the unit and the spacing of the value and the unit.
struct ZeroValueUnitsDisplayStrategy
Specifies how zero value units are handled.