StructureSwift
Duration.TimeFormatStyle
iOS 16.0+
iPadOS 16.0+
Mac Catalyst 16.0+
macOS 13.0+
tvOS 16.0+
watchOS 9.0+
Format style to format a
Duration in a localized positional format. For example, one hour and ten minutes is displayed as “1:10:00” in the U.S. English locale, or “1.10.00” in the Finnish locale.struct TimeFormatStyle
Topics
Structures
struct AttributedFormats a duration as an attributed string with thedurationFieldattribute key andFoundationAttributes.DurationFieldAttributeattribute.struct PatternThe units to display a Duration with and configurations for the units.
Initializers
init(from: any Decoder) throwsinit(pattern: Duration.TimeFormatStyle.Pattern, locale: Locale)Creates an instance using the provided pattern and locale.
Instance Properties
var attributed: Duration.TimeFormatStyle.AttributedThe attributed format style corresponding to this style.var grouping: NumberFormatStyleConfiguration.GroupingThegroupingrule applied to high number values on the largest field in the pattern.var locale: LocaleThe locale to use when formatting the duration.var pattern: Duration.TimeFormatStyle.PatternThe pattern to display a Duration with.
Instance Methods
func format(Duration) -> StringCreates a locale-aware string representation from a duration value.func grouping(NumberFormatStyleConfiguration.Grouping) -> Duration.TimeFormatStyleReturns a modified style that applies the givengroupingrule to the highest field in the pattern.func locale(Locale) -> Duration.TimeFormatStyleModifies the format style to use the specified locale.
Default Implementations
Relationships
Conforms To
DiscreteFormatStyleFormatStyleSwift.CopyableSwift.DecodableSwift.EncodableSwift.EquatableSwift.EscapableSwift.HashableSwift.SendableSwift.SendableMetatype