Date.FormatStyle.Symbol.Weekday
A type that specifies the format for the weekday name in a date format style.
Declaration
struct WeekdayOverview
The type Date.FormatStyle.Symbol.Weekday includes static factory variables that create custom Date.FormatStyle.Symbol.Weekday objects:
Factory variable | Description |
|---|---|
Abbreviated weekday name. For example, | |
Wide weekday name. For example, | |
Narrow weekday name. For example, | |
Short weekday name. For example, | |
Local numeric one-digit day of week. The value depends on the local starting day of the week. For example, this is | |
Local numeric two-digit day of week, zero-padded if necessary. The value depends on the local starting day of the week. For example, this is |
To customize the weekday, name format in a string representation of a Date, use weekday(_:). This example shows a variety of Date.FormatStyle.Symbol.Weekday format styles applied to a Thursday, using locale en_US:
let meetingDate = Date() // Feb 18, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().weekday(.abbreviated)) // Thu
meetingDate.formatted(Date.FormatStyle().weekday(.narrow)) // T
meetingDate.formatted(Date.FormatStyle().weekday(.short)) // Th
meetingDate.formatted(Date.FormatStyle().weekday(.wide)) // Thursday
meetingDate.formatted(Date.FormatStyle().weekday(.oneDigit)) // 5
meetingDate.formatted(Date.FormatStyle().weekday(.twoDigits)) // 05
meetingDate.formatted(Date.FormatStyle().weekday()) // ThuIf 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 a Weekday
Comparing a Weekday
Type Properties
See Also
Modifying Date Style Format Symbols
Date.FormatStyle.Symbol.CyclicYearDate.FormatStyle.Symbol.DayDate.FormatStyle.Symbol.DayOfYearDate.FormatStyle.Symbol.DayPeriodDate.FormatStyle.Symbol.EraDate.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.TimeZone