One Logo Pool Ball
Foundation · IOS API REFERENCE

Date.IntervalFormatStyle

struct · iOS 15.0+ · SDK 27.1

struct IntervalFormatStyle

A format style that creates string representations of date intervals. Use `Date.IntervalFormatStyle` to create user-readable strings of date intervals. The format style provides customization to show specific date and time components.

Members (17)

method · iOS 15.0+

day

TypeScript
day(): Date_IntervalFormatStyle
Swift declaration
func day() -> Date.IntervalFormatStyle

Modifies the date interval format style to include the day. - Returns: A date interval format style that includes the day.

init · iOS 15.0+

init

TypeScript
static init(date?: (Date_FormatStyle_DateStyle) | null, time?: (Date_FormatStyle_TimeStyle) | null, locale?: Locale, calendar?: Calendar, timeZone?: TimeZone): Date_IntervalFormatStyle
Swift declaration
init(date: Date.IntervalFormatStyle.DateStyle? = nil, time: Date.IntervalFormatStyle.TimeStyle? = nil, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, timeZone: TimeZone = .autoupdatingCurrent)

Creates a new `FormatStyle` with the given configurations. - Parameters: - date: The style for formatting the date part of the given date pairs. Note that if `.omitted` is specified, but the date interval spans more than one day, a locale-specific fallback will be used. - time: The style for formatting the time part of the given date pairs. - locale: The locale to use when formatting date and time values. - calendar: The calendar to use for date values. - timeZone: The time zone with which to specify date and time values. - Important: Always specify the date length, time length, or the date components to be included in the formatted string with the symbol modifiers. Otherwise, an empty string will be returned when you use the instance to format an object. - Note: If specifying the date fields, and the `DateInterval` range is larger than the specified units, a locale-specific fallback will be used. - Example: for the range 2010-03-04 07:56 - 2010-03-08 16:11 (4 days, 8 hours, 15 minutes), specifying `.hour().minute()` will produce - for en_US, "3/4/2010 7:56 AM - 3/8/2010 4:11 PM" - for en_GB, "4/3/2010 7:56 - 8/3/2010 16:11"

method · iOS 15.0+

hour

TypeScript
hour(format?: Date_FormatStyle_Symbol_Hour): Date_IntervalFormatStyle
Swift declaration
func hour(_ format: Date.IntervalFormatStyle.Symbol.Hour = .defaultDigits(amPM: .abbreviated)) -> Date.IntervalFormatStyle

Modifies the date interval format style to include the hour. - Parameter format: The hour format style to apply. - Returns: A date interval format style that includes the specified hour style.

method · iOS 15.0+

year

TypeScript
year(): Date_IntervalFormatStyle
Swift declaration
func year() -> Date.IntervalFormatStyle

Modifies the date interval format style to include the year. - Returns: A date interval format style that includes the year.

method · iOS 15.0+

month

TypeScript
month(format?: Date_FormatStyle_Symbol_Month): Date_IntervalFormatStyle
Swift declaration
func month(_ format: Date.IntervalFormatStyle.Symbol.Month = .abbreviated) -> Date.IntervalFormatStyle

Modifies the date interval format style to include the month. - Parameter format: The month format style to apply. - Returns: A date interval format style that includes the specified month style.

method · iOS 15.0+

format

TypeScript
format(v: SDKHandle): string
Swift declaration
func format(_ v: Range<Date>) -> String

Creates a locale-aware string representation from a date interval. - Parameter v: The date range to format. - Returns: A string representation of the date range.

get · iOS 15.0+

locale

TypeScript
get locale(): Locale
Swift declaration
var locale: Locale

The locale to use when formatting date interval values.

set · iOS 15.0+

locale

TypeScript
set locale(value: Locale)
Swift declaration
var locale: Locale

The locale to use when formatting date interval values.

method · iOS 15.0+

locale

TypeScript
locale11491(locale: Locale): Date_IntervalFormatStyle
Swift declaration
func locale(_ locale: Locale) -> Date.IntervalFormatStyle

Modifies the date interval format style to use the specified locale. - Parameter locale: The locale for formatting a date interval. - Returns: A date interval format style with the provided locale.

method · iOS 15.0+

minute

TypeScript
minute(): Date_IntervalFormatStyle
Swift declaration
func minute() -> Date.IntervalFormatStyle

Modifies the date interval format style to include the minute. - Returns: A date interval format style that includes the minute.

method · iOS 15.0+

second

TypeScript
second(): Date_IntervalFormatStyle
Swift declaration
func second() -> Date.IntervalFormatStyle

Modifies the date interval format style to include the second. - Returns: A date interval format style that includes the second.

method · iOS 15.0+

weekday

TypeScript
weekday(format?: Date_FormatStyle_Symbol_Weekday): Date_IntervalFormatStyle
Swift declaration
func weekday(_ format: Date.IntervalFormatStyle.Symbol.Weekday = .abbreviated) -> Date.IntervalFormatStyle

Modifies the date interval format style to include the weekday. - Parameter format: The weekday format style to apply. - Returns: A date interval format style that includes the specified weekday style.

get · iOS 15.0+

calendar

TypeScript
get calendar(): Calendar
Swift declaration
var calendar: Calendar

The calendar to use for date values.

set · iOS 15.0+

calendar

TypeScript
set calendar(value: Calendar)
Swift declaration
var calendar: Calendar

The calendar to use for date values.

get · iOS 15.0+

timeZone

TypeScript
get timeZone(): TimeZone
Swift declaration
var timeZone: TimeZone

The time zone with which to specify date and time values.

set · iOS 15.0+

timeZone

TypeScript
set timeZone(value: TimeZone)
Swift declaration
var timeZone: TimeZone

The time zone with which to specify date and time values.

method · iOS 15.0+

timeZone

TypeScript
timeZone13383(format?: Date_FormatStyle_Symbol_TimeZone): Date_IntervalFormatStyle
Swift declaration
func timeZone(_ format: Date.IntervalFormatStyle.Symbol.TimeZone = .genericName(.short)) -> Date.IntervalFormatStyle

Modifies the date interval format style to include the time zone. - Parameter format: The time zone format style to apply. - Returns: A date interval format style that includes the specified time zone style.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →