A type that specifies the format for a day in a date format style.
The ``Date/FormatStyle/Symbol/Day`` type includes static factory variables and methods that create custom ``Date/FormatStyle/Symbol/Day`` objects:
|Factory variable|Description|
|---|---|
| ``defaultDigits`` | The minimum number of digits that shows the numeric day of month. For example, `1`, `18`. |
| ``julianModified(minimumLength:)`` | The modified Julian day. The field length specifies the minimum number of digits, zero-padded if necessary. For example, `2451334`. |
| ``ordinalOfDayInMonth`` | The ordinal of the day in the month. For example, the second Wednesday in July would yield `2`. |
| ``twoDigits`` | The two-digit numeric day of month, zero-padded if necessary. For example, `01`, `18`. |
To customize the day format in a string representation of a `Date`, use ``Date/FormatStyle/day(_:)``. The following example shows a variety of ``Date/FormatStyle/Symbol/Day`` formats applied to a date.
```swift
let meetingDate = Date() // Feb 9, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().day(.defaultDigits)) // 9
meetingDate.formatted(Date.FormatStyle().day(.ordinalOfDayInMonth)) // 2 (second Tuesday of the month)
meetingDate.formatted(Date.FormatStyle().day(.twoDigits)) // 09
meetingDate.formatted(Date.FormatStyle().day(.julianModified(minimumLength: 12))) // 0002459255
meetingDate.formatted(Date.FormatStyle().day()) // 9
```
If no format is specified as a parameter, the ``defaultDigits`` static variable is the default format.
For more information about formatting dates, see the ``Date/FormatStyle``.
Members (5)
get · iOS 15.0+
ordinalOfDayInMonth
TypeScript
static get ordinalOfDayInMonth(): Date_FormatStyle_Symbol_Day
Swift declaration
static var ordinalOfDayInMonth: Date.FormatStyle.Symbol.Day { get }
Ordinal of day in month.
For example, the 2nd Wed in July would yield `2`.
get · iOS 15.0+
defaultDigits
TypeScript
static get defaultDigits(): Date_FormatStyle_Symbol_Day
Swift declaration
static var defaultDigits: Date.FormatStyle.Symbol.Day { get }
Minimum number of digits that shows the full numeric day of month. For example, `1`, `18`.
static func julianModified(minimumLength: Int = 1) -> Date.FormatStyle.Symbol.Day
The field length specifies the minimum number of digits, with zero-padding as necessary.
This is different from the conventional Julian day number in two regards. First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number; that is, it depends on the local time zone. It can be thought of as a single number that encompasses all the date-related fields.
For example, `2451334`.
get · iOS 18.0+
omitted
TypeScript
static get omitted(): Date_FormatStyle_Symbol_Day
Swift declaration
static let omitted: Date.FormatStyle.Symbol.Day
The option for not including the symbol in the formatted output.
get · iOS 15.0+
twoDigits
TypeScript
static get twoDigits(): Date_FormatStyle_Symbol_Day
Swift declaration
static var twoDigits: Date.FormatStyle.Symbol.Day { get }
Two-digit, zero-padded if necessary. For example, `01`, `18`.