UnitsStyle
- iOS
- 15.0+
- macOS
- 12.0+
- tvOS
- 15.0+
- watchOS
- 8.0+
struct UnitsStyle
struct UnitsStyle
s20FoundationEssentials4DateV0A20InternationalizationE19RelativeFormatStyleV05UnitsG0V
What are these?1XIBM
import FoundationInternationalization
import FoundationEssentials
struct RelativeFormatStyle
struct Date
Date
represents a single point in time.
init(allowedFields: Set<Date.RelativeFormatStyle.Field>, presentation: Date.RelativeFormatStyle.Presentation = .numeric, unitsStyle: Date.RelativeFormatStyle.UnitsStyle = .wide, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, capitalizationContext: FormatStyleCapitalizationContext = .unknown)
init(from decoder: any Decoder) throws
init(presentation: Date.RelativeFormatStyle.Presentation = .numeric, unitsStyle: Date.RelativeFormatStyle.UnitsStyle = .wide, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, capitalizationContext: FormatStyleCapitalizationContext = .unknown)
var allowedFields: Set<Date.RelativeFormatStyle.Field> { get set }
The fields that can be used in the formatted output.
var calendar: Calendar
var capitalizationContext: FormatStyleCapitalizationContext
var locale: Locale
var presentation: Date.RelativeFormatStyle.Presentation
var unitsStyle: Date.RelativeFormatStyle.UnitsStyle
func format(_ destDate: Date) -> String
func locale(_ locale: Locale) -> Date.RelativeFormatStyle
struct Presentation
typealias Field = Date.ComponentsFormatStyle.Field
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Sendable
init(from decoder: any Decoder) throws
static var abbreviated: Date.RelativeFormatStyle.UnitsStyle { get }
“2 mo. ago”, “next Wed.”
static var narrow: Date.RelativeFormatStyle.UnitsStyle { get }
“2 mo. ago”, “next W”
static var spellOut: Date.RelativeFormatStyle.UnitsStyle { get }
“two months ago”, “next Wednesday”
static var wide: Date.RelativeFormatStyle.UnitsStyle { get }
“2 months ago”, “next Wednesday”
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.