StructureFoundationInternationalization
Duration.UnitsFormatStyle.Attributed
iOS 16.0+
iPadOS 16.0+
Mac Catalyst 16.0+
macOS 13.0+
tvOS 16.0+
watchOS 9.0+
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.@dynamicMemberLookup struct Attributed
Overview
You can use Duration.UnitsFormatStyle to configure the style, and create an Attributed format with its public var attributed: Attributed
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 }
Topics
Initializers
Instance Methods
func format(Duration) -> AttributedStringFormats a duration as an attributed string withDurationFieldAttribute.func locale(Locale) -> Duration.UnitsFormatStyle.AttributedA modifier to set the locale of the format style.
Subscripts
Default Implementations
Relationships
Conforms To
DiscreteFormatStyleFormatStyleSwift.CopyableSwift.DecodableSwift.EncodableSwift.EquatableSwift.EscapableSwift.HashableSwift.SendableSwift.SendableMetatype