StructureFoundationEssentials
Date.IntervalFormatStyle
iOS 15.0+
iPadOS 15.0+
Mac Catalyst 15.0+
macOS 12.0+
tvOS 15.0+
watchOS 8.0+
A format style that creates string representations of date intervals.
struct IntervalFormatStyle
Overview
Use Date.IntervalFormatStyle to create user-readable strings of date intervals. The format style provides customization to show specific date and time components.
Topics
Initializers
init(date: Date.IntervalFormatStyle.DateStyle?, time: Date.IntervalFormatStyle.TimeStyle?, locale: Locale, calendar: Calendar, timeZone: TimeZone)Creates a newFormatStylewith the given configurations.init(from: any Decoder) throws
Instance Properties
var calendar: CalendarThe calendar to use for date values.var locale: LocaleThe locale to use when formatting date interval values.var timeZone: TimeZoneThe time zone with which to specify date and time values.
Instance Methods
func day() -> Date.IntervalFormatStyleModifies the date interval format style to include the day.func format(Range<Date>) -> StringCreates a locale-aware string representation from a date interval.func hour(Date.IntervalFormatStyle.Symbol.Hour) -> Date.IntervalFormatStyleModifies the date interval format style to include the hour.func locale(Locale) -> Date.IntervalFormatStyleModifies the date interval format style to use the specified locale.func minute() -> Date.IntervalFormatStyleModifies the date interval format style to include the minute.func month(Date.IntervalFormatStyle.Symbol.Month) -> Date.IntervalFormatStyleModifies the date interval format style to include the month.func second() -> Date.IntervalFormatStyleModifies the date interval format style to include the second.func timeZone(Date.IntervalFormatStyle.Symbol.TimeZone) -> Date.IntervalFormatStyleModifies the date interval format style to include the time zone.func weekday(Date.IntervalFormatStyle.Symbol.Weekday) -> Date.IntervalFormatStyleModifies the date interval format style to include the weekday.func year() -> Date.IntervalFormatStyleModifies the date interval format style to include the year.
Type Aliases
typealias DateStyleThe type that defines date interval styles that vary in length or in their included components.typealias SymbolThe type that supports customizing formatting templates using the date format style’s modifier functions, and constructing fixed-pattern date format strings.typealias TimeStyleThe type that defines time styles that vary in length or in their included components.
Relationships
Conforms To
FormatStyleSwift.CopyableSwift.DecodableSwift.EncodableSwift.EquatableSwift.EscapableSwift.HashableSwift.SendableSwift.SendableMetatype