One Logo Pool Ball
Foundation · IOS API REFERENCE

Date.FormatStyle.Attributed

struct · iOS 18.0+ · SDK 27.1

@dynamicMemberLookup struct Attributed

The type preserving attributed variant of this style. This style attributes the formatted date with the `AttributeScopes.FoundationAttributes.DateFormatFieldAttribute`.

Members (21)

method · iOS 18.0+

discreteInput

TypeScript
discreteInputAfter(input: globalThis.Date): (globalThis.Date) | null
Swift declaration
func discreteInput(after input: Date) -> Date?

The next discretization boundary after the given input. Use this function to determine the next "greater" input that warrants updating the formatted output. The following example prints all possible outputs the format style can produce upwards starting from the `startInput`: ```swift var previousInput = startInput while let nextInput = style.discreteInput(after: previousInput) { print(style.format(nextInput)) previousInput = nextInput } ``` - Returns: For most `input`s, the method returns the "smallest" value "greater" than `input` for which the style produces a different ``FormatStyle/FormatOutput``, or `nil` if no such value exists. For some input values, the function may also return a value "greater" than `input` for which the style still produces the same ``FormatStyle/FormatOutput`` as for `input`.

method · iOS 18.0+

discreteInput

TypeScript
discreteInputBefore(input: globalThis.Date): (globalThis.Date) | null
Swift declaration
func discreteInput(before input: Date) -> Date?

The next discretization boundary before the given input. Use this function to determine the next "smaller" input that warrants updating the formatted output. The following example prints all possible outputs the format style can produce downwards starting from the `startInput`: ```swift var previousInput = startInput while let nextInput = style.discreteInput(before: previousInput) { print(style.format(nextInput)) previousInput = nextInput } ``` - Returns: For most `input`s, the method returns the "greatest" value "smaller" than `input` for which the style produces a different ``FormatStyle/FormatOutput``, or `nil` if no such value exists. For some input values, the function may also return a value "smaller" than `input` for which the style still produces the same ``FormatStyle/FormatOutput`` as for `input`.

subscript · iOS 18.0+

subscript

TypeScript
subscriptDynamicMember(key: SDKHandle): unknown
Swift declaration
subscript<T>(dynamicMember key: WritableKeyPath<Date.FormatStyle, T>) -> T { get set }
subscript · iOS 18.0+

subscript

TypeScript
subscriptDynamicMember29551(key: SDKHandle): unknown
Swift declaration
subscript<T>(dynamicMember key: KeyPath<Date.FormatStyle, T>) -> T { get }
method · iOS 18.0+

secondFraction

TypeScript
secondFraction(format: Date_FormatStyle_Symbol_SecondFraction): Date_FormatStyle_Attributed
Swift declaration
func secondFraction(_ format: Date.FormatStyle.Symbol.SecondFraction) -> Date.FormatStyle.Attributed

Change the representation of the second fraction in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

day

TypeScript
day(format?: Date_FormatStyle_Symbol_Day): Date_FormatStyle_Attributed
Swift declaration
func day(_ format: Date.FormatStyle.Symbol.Day = .defaultDigits) -> Date.FormatStyle.Attributed

Change the representation of the day of the month in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

era

TypeScript
era(format?: Date_FormatStyle_Symbol_Era): Date_FormatStyle_Attributed
Swift declaration
func era(_ format: Date.FormatStyle.Symbol.Era = .abbreviated) -> Date.FormatStyle.Attributed

Change the representation of the era in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

hour

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

Change the representation of the hour in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

week

TypeScript
week(format?: Date_FormatStyle_Symbol_Week): Date_FormatStyle_Attributed
Swift declaration
func week(_ format: Date.FormatStyle.Symbol.Week = .defaultDigits) -> Date.FormatStyle.Attributed

Change the representation of the week in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

year

TypeScript
year(format?: Date_FormatStyle_Symbol_Year): Date_FormatStyle_Attributed
Swift declaration
func year(_ format: Date.FormatStyle.Symbol.Year = .defaultDigits) -> Date.FormatStyle.Attributed

Change the representation of the year in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

input

TypeScript
inputAfter(input: globalThis.Date): (globalThis.Date) | null
Swift declaration
func input(after input: Date) -> Date?

The next input value after the given input. Use this function to determine if the return value provided by ``discreteInput(before:)`` is precise enough for your use case for any input `y`: ```swift guard let x = style.discreteInput(before: y) else { return } let z = style.input(after: x) ?? y ``` If the distance between `x` and `z` is too large for the precision you require, you may want to manually probe ``FormatStyle/format(_:)`` at a higher rate in that interval, as there is no guarantee for what the output will be in that interval. - Returns: The next "greater" input value that can be represented by ``FormatStyle/FormatInput`` or an underlying representation the format style uses internally.

method · iOS 18.0+

input

TypeScript
inputBefore(input: globalThis.Date): (globalThis.Date) | null
Swift declaration
func input(before input: Date) -> Date?

The next input value before the given input. Use this function to determine if the return value provided by ``discreteInput(after:)`` is precise enough for your use case for any input `y`: ```swift guard let x = style.discreteInput(after: y) else { return } let z = style.input(before: x) ?? y ``` If the distance between `z` and `x` is too large for the precision you require, you may want to manually probe ``FormatStyle/format(_:)`` at a higher rate in that interval, as there is no guarantee for what the output will be in that interval. - Returns: The next "smalller" input value that can be represented by ``FormatStyle/FormatInput`` or an underlying representation the format style uses internally.

method · iOS 18.0+

month

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

Change the representation of the month in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

format

TypeScript
format(value: globalThis.Date): AttributedString
Swift declaration
func format(_ value: Date) -> AttributedString

Creates a locale-aware attributed string representation from a date value. - Parameter value: The date to format. - Returns: An attributed string representation of the date.

method · iOS 18.0+

locale

TypeScript
locale(locale: Locale): Date_FormatStyle_Attributed
Swift declaration
func locale(_ locale: Locale) -> Date.FormatStyle.Attributed

Modifies the date attributed style to use the specified locale. - Parameter locale: The locale to use when formatting a date. - Returns: A date attributed style with the provided locale.

method · iOS 18.0+

minute

TypeScript
minute(format?: Date_FormatStyle_Symbol_Minute): Date_FormatStyle_Attributed
Swift declaration
func minute(_ format: Date.FormatStyle.Symbol.Minute = .defaultDigits) -> Date.FormatStyle.Attributed

Change the representation of the minute in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

second

TypeScript
second(format?: Date_FormatStyle_Symbol_Second): Date_FormatStyle_Attributed
Swift declaration
func second(_ format: Date.FormatStyle.Symbol.Second = .defaultDigits) -> Date.FormatStyle.Attributed

Change the representation of the second in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

quarter

TypeScript
quarter(format?: Date_FormatStyle_Symbol_Quarter): Date_FormatStyle_Attributed
Swift declaration
func quarter(_ format: Date.FormatStyle.Symbol.Quarter = .abbreviated) -> Date.FormatStyle.Attributed

Change the representation of the quarter in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

weekday

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

Change the representation of the weekday in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

timeZone

TypeScript
timeZone(format?: Date_FormatStyle_Symbol_TimeZone): Date_FormatStyle_Attributed
Swift declaration
func timeZone(_ format: Date.FormatStyle.Symbol.TimeZone = .specificName(.short)) -> Date.FormatStyle.Attributed

Change the representation of the time zone in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

method · iOS 18.0+

dayOfYear

TypeScript
dayOfYear(format?: Date_FormatStyle_Symbol_DayOfYear): Date_FormatStyle_Attributed
Swift declaration
func dayOfYear(_ format: Date.FormatStyle.Symbol.DayOfYear = .defaultDigits) -> Date.FormatStyle.Attributed

Change the representation of the day of the year in the format. - Parameter format: Set the symbol representation or pass `nil` to remove it.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →