Structure
Date.FormatStyle.Symbol.Day
struct Day
Overview
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()) // 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.
Topics
Type Properties
static var defaultDigits: Date.FormatStyle.Symbol.DayMinimum number of digits that shows the full numeric day of month. For example,1,18.static let omitted: Date.FormatStyle.Symbol.DayThe option for not including the symbol in the formatted output.static var ordinalOfDayInMonth: Date.FormatStyle.Symbol.DayOrdinal of day in month. For example, the 2nd Wed in July would yield2.static var twoDigits: Date.FormatStyle.Symbol.DayTwo-digit, zero-padded if necessary. For example,01,18.
Type Methods
static func julianModified(minimumLength: Int) -> Date.FormatStyle.Symbol.DayThe 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.
Relationships
Conforms To
Swift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype