A format style that forms locale-aware string representations of a relative date or time.
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
宣言
structRelativeFormatStyle
Overview
概要
Use the strings that the format style produces, such as “1 hour ago”, “in 2 weeks”, “yesterday”, and “tomorrow” as standalone strings. Embedding them in other strings may not be grammatically correct.
それらを他の文字列の中に埋め込むことは、文法的に正しくないかもしれません。
Express relative date formats in either numeric or named styles. For example:
例えば:
Use the convenient static factory method relative(presentation:unitsStyle:) to shorten the syntax when applying presentation and units style modifiers to customize the format. For example:
例えば:
The format(_:) instance method generates a string from the provided relative date.format(_:)インスタンスメソッドは、ある文字列をこの提供された相対日付から生成します。
Once you create a style, you can use it to format relative dates multiple times.
The following example applies a format style repeatedly to produce string representations of relative dates:
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”。
A type that represents the style to use when formatting relative dates, such as “1 week ago” or “last week”.
ある型、それは相対日付を書式設定する時に使う様式を表します、たとえば “1 week ago” または “last week”。