The style to use when describing a relative date, such as “1 day ago” or “yesterday”.
Initializerinit(presentation:
init(presentation:unitsStyle:locale:calendar:capitalizationContext:)
Creates a relative date format style with the specified presentation, units, locale, calendar, and capitalization context.
Availability 有効性
- iOS 15.0+
- iPadOS 15.0+
- macOS 12.0+
- Mac Catalyst 15.0+
- tvOS 15.0+
- watchOS 8.0+
- Xcode 13.0+
Technology
- Foundation ファウンデーション
Declaration 宣言
init(presentation: Date
.RelativeFormatStyle
.Presentation
= .numeric, unitsStyle: Date
.RelativeFormatStyle
.UnitsStyle
= .wide, locale: Locale
= .autoupdatingCurrent, calendar: Calendar
= .autoupdatingCurrent, capitalizationContext: FormatStyleCapitalizationContext
= .unknown)
Parameters パラメータ
presentation
unitsStyle
The style to use when formatting the quantity or the name of the unit, such as “1 day ago” or “one day ago”. 単位の量または名前を書式設定する時に使う様式、たとえば “1 day ago” または “one day ago”。
locale
The locale to use when formatting the relative date.
calendar
The calendar to use when formatting the relative date.
capitalizationContext
The capitalization context to use when formatting the relative date.
Discussion 議論
The following example creates a format style applied to a relative date to create a string representation.