AnchoredRelativeFormatStyle
A relative format style that is detached from the system time, and instead formats an anchor date relative to the format input.
- iOS
- 16.4+
- macOS
- 13.3+
- tvOS
- 16.4+
- watchOS
- 9.4+
struct AnchoredRelativeFormatStyle
A relative format style that is detached from the system time, and instead formats an anchor date relative to the format input.
struct AnchoredRelativeFormatStyle
s20FoundationEssentials4DateV0A20InternationalizationE27AnchoredRelativeFormatStyleV
What are these?2E55G
import FoundationEssentials
import FoundationInternationalization
struct Date
Date
represents a single point in time.
func formatted() -> String
func formatted(date: Date.FormatStyle.DateStyle, time: Date.FormatStyle.TimeStyle) -> String
Converts self
to its textual representation that contains both the date and time parts. The exact format depends on the user’s preferences.
struct AttributedStyle
struct ComponentsFormatStyle
struct FormatString
struct FormatStyle
Strategies for formatting a Date
.
struct IntervalFormatStyle
struct ParseStrategy
Options for parsing string representations of dates to create a Date
instance.
struct RelativeFormatStyle
struct VerbatimFormatStyle
Formats a Date
using the given format.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Decodable
A type that can decode itself from an external representation.
protocol DiscreteFormatStyle<FormatInput, FormatOutput> : FormatStyle
A format style that transforms a continuous input into a discrete output and provides information about its discretization boundaries.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol FormatStyle : Decodable, Encodable, Hashable
A type that can convert a given data type into a representation.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Sendable
init(anchor: Date, allowedFields: Set<Date.AnchoredRelativeFormatStyle.Field>, presentation: Date.AnchoredRelativeFormatStyle.Presentation = .numeric, unitsStyle: Date.AnchoredRelativeFormatStyle.UnitsStyle = .wide, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, capitalizationContext: FormatStyleCapitalizationContext = .unknown)
Create a relative format style that is detached from the system time, and instead formats an anchor date relative to the format input.
init(anchor: Date, presentation: Date.AnchoredRelativeFormatStyle.Presentation = .numeric, unitsStyle: Date.AnchoredRelativeFormatStyle.UnitsStyle = .wide, locale: Locale = .autoupdatingCurrent, calendar: Calendar = .autoupdatingCurrent, capitalizationContext: FormatStyleCapitalizationContext = .unknown)
Create a relative format style that is detached from the system time, and instead formats an anchor date relative to the format input.
init(from decoder: any Decoder) throws
var allowedFields: Set<Date.AnchoredRelativeFormatStyle.Field> { get set }
The fields that can be used in the formatted output.
var anchor: Date
The date the formatted output refers to from the perspective of the input values.
var calendar: Calendar { get set }
var capitalizationContext: FormatStyleCapitalizationContext { get set }
var locale: Locale { get set }
var presentation: Date.AnchoredRelativeFormatStyle.Presentation { get set }
var unitsStyle: Date.AnchoredRelativeFormatStyle.UnitsStyle { get set }
func discreteInput(after input: Date) -> Date?
func discreteInput(before input: Date) -> Date?
func format(_ input: Date) -> String
func input(after input: Date) -> Date?
func input(before input: Date) -> Date?
func locale(_ locale: Locale) -> Date.AnchoredRelativeFormatStyle
typealias Field = Date.RelativeFormatStyle.Field
typealias Presentation = Date.RelativeFormatStyle.Presentation
typealias UnitsStyle = Date.RelativeFormatStyle.UnitsStyle
static func currency<Value>(code: String) -> Self where Self == FloatingPointFormatStyle<Value>.Currency, Value : BinaryFloatingPoint
static func currency<V>(code: String) -> Self where Self == IntegerFormatStyle<V>.Currency, V : BinaryInteger
static func list<MemberStyle, Base>(memberStyle: MemberStyle, type: ListFormatStyle<MemberStyle, Base>.ListType, width: ListFormatStyle<MemberStyle, Base>.Width = .standard) -> Self where Self == ListFormatStyle<MemberStyle, Base>, MemberStyle : FormatStyle, Base : Sequence, MemberStyle.FormatInput == Base.Element, MemberStyle.FormatOutput == String
static func list<Base>(type: ListFormatStyle<StringStyle, Base>.ListType, width: ListFormatStyle<StringStyle, Base>.Width = .standard) -> Self where Self == ListFormatStyle<StringStyle, Base>, Base : Sequence, Base.Element == String
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.