Date.FormatStyle.Symbol.Era
A type that specifies a format for the era in a date format style.
Declaration
struct EraOverview
The type Date.FormatStyle.Symbol.Era includes static factory variables that create custom Date.FormatStyle.Symbol.Era objects.
Factory variable | Description |
|---|---|
An abbreviated representation of an era. For example, | |
A narrow era representation. For example, | |
A full representation of an era. For example, |
To customize the era format in a string representation of a Date, use era(_:). The following example shows a variety of Date.FormatStyle.Symbol.Era format styles applied to a date.
let meetingDate = Date() // Feb 9, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().era(.abbreviated)) // AD
meetingDate.formatted(Date.FormatStyle().era(.narrow)) // A
meetingDate.formatted(Date.FormatStyle().era(.wide)) // Anno Domini
meetingDate.formatted(Date.FormatStyle().era()) // ADIf no format is specified as a parameter, the abbreviated static variable is the default format.
For more information about formatting dates, see the Date.FormatStyle.
Topics
Modifying an Era
Comparing an Era
Type Properties
See Also
Modifying Date Style Format Symbols
Date.FormatStyle.Symbol.CyclicYearDate.FormatStyle.Symbol.DayDate.FormatStyle.Symbol.DayOfYearDate.FormatStyle.Symbol.DayPeriodDate.FormatStyle.Symbol.HourDate.FormatStyle.Symbol.MinuteDate.FormatStyle.Symbol.MonthDate.FormatStyle.Symbol.QuarterDate.FormatStyle.Symbol.SecondDate.FormatStyle.Symbol.SecondFractionDate.FormatStyle.Symbol.StandaloneMonthDate.FormatStyle.Symbol.StandaloneQuarterDate.FormatStyle.Symbol.StandaloneWeekdayDate.FormatStyle.Symbol.TimeZoneDate.FormatStyle.Symbol.VerbatimHour