attributed
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.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
var attributed: Duration.UnitsFormatStyle.Attributed { get }
For example, formatting a duration of 2 hours, 43 minutes, 26.25 second in en_US
locale yeilds the following conceptually
2 { durationField: .hours, component: .value }
hours { durationField: .hours, component: .unit }
, { nil }
43 { durationField: .minutes, component: .value }
minutes { durationField: .minutes, component: .unit }
, { nil }
26.25 { durationField: .seconds, component: .value }
seconds { durationField: .seconds, component: .unit }