pattern
The pattern to display a Duration with.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
var pattern: Duration.TimeFormatStyle.Pattern { get set }
The pattern to display a Duration with.
var pattern: Duration.TimeFormatStyle.Pattern { get set }
ss8DurationV30FoundationInternationalizationE15TimeFormatStyleV7patternAE7PatternVvp
What are these?5DINC
import Swift
import FoundationInternationalization
struct TimeFormatStyle
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.
@frozen struct Duration
A representation of high precision time.
struct Pattern
The units to display a Duration with and configurations for the units.
init(from decoder: any Decoder) throws
init(pattern: Duration.TimeFormatStyle.Pattern, locale: Locale = .autoupdatingCurrent)
Creates an instance using the provided pattern and locale.
var attributed: Duration.TimeFormatStyle.Attributed { get }
The attributed format style corresponding to this style.
var grouping: NumberFormatStyleConfiguration.Grouping { get set }
The grouping
rule applied to high number values on the largest field in the pattern.
var locale: Locale { get set }
The locale to use when formatting the duration.
func discreteInput(after input: Duration) -> Duration?
func discreteInput(before input: Duration) -> Duration?
func format(_ value: Duration) -> String
Creates a locale-aware string representation from a duration value.
func grouping(_ grouping: NumberFormatStyleConfiguration.Grouping) -> Duration.TimeFormatStyle
Returns a modified style that applies the given grouping
rule to the highest field in the pattern.
func locale(_ locale: Locale) -> Duration.TimeFormatStyle
Modifies the format style to use the specified locale.
@dynamicMemberLookup struct Attributed
Formats a duration as an attributed string with the durationField
attribute key and FoundationAttributes.DurationFieldAttribute
attribute.