Date.FormatStyle.Symbol.Day
A type that specifies the format for a day in a date format style.
Declaration
struct DayOverview
The Date.FormatStyle.Symbol.Day type includes static factory variables and methods that create custom Date.FormatStyle.Symbol.Day objects:
Factory variable | Description |
|---|---|
The minimum number of digits that shows the numeric day of month. For example, | |
The modified Julian day. The field length specifies the minimum number of digits, zero-padded if necessary. For example, | |
The ordinal of the day in the month. For example, the second Wednesday in July would yield | |
The two-digit numeric day of month, zero-padded if necessary. For example, |
To customize the day format in a string representation of a Date, use day(_:). The following example shows a variety of Date.FormatStyle.Symbol.Day formats applied to a date.
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()) // 9If 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.
Topics
Modifying a Day Format
Comparing Day Formats
Type Properties
See Also
Modifying Date Style Format Symbols
Date.FormatStyle.Symbol.CyclicYearDate.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.TimeZoneDate.FormatStyle.Symbol.VerbatimHour