Skip to content

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

Subscripts

Default Implementations

Relationships

Conforms To

  • DiscreteFormatStyle
  • FormatStyle
  • Swift.Copyable
  • Swift.Decodable
  • Swift.Encodable
  • Swift.Equatable
  • Swift.Escapable
  • Swift.Hashable
  • Swift.Sendable
  • Swift.SendableMetatype