Structure
Date.FormatStyle.Symbol.Weekday
struct Weekday
Overview
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()) // Thu
If 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
Type Properties
static var abbreviated: Date.FormatStyle.Symbol.WeekdayAbbreviated day of week name. For example, “Tue”.static var narrow: Date.FormatStyle.Symbol.WeekdayNarrow day of week name. For example, “T”.static let omitted: Date.FormatStyle.Symbol.WeekdayThe option for not including the symbol in the formatted output.static var oneDigit: Date.FormatStyle.Symbol.WeekdayLocal day of week number/name. The value depends on the local starting day of the week.static var short: Date.FormatStyle.Symbol.WeekdayShort day of week name. For example, “Tu”.static var twoDigits: Date.FormatStyle.Symbol.WeekdayLocal day of week number/name, format style; two digits, zero-padded if necessary.static var wide: Date.FormatStyle.Symbol.WeekdayWide day of week name. For example, “Tuesday”.
Relationships
Conforms To
Swift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype