Structure
Date.FormatStyle.Symbol.Month
struct Month
Overview
The type Date.FormatStyle.Symbol.Month includes static factory variables that create custom Date.FormatStyle.Symbol.Month objects:
Factory variable |
Description |
|---|---|
Abbreviated month name. For example, |
|
Minimum number of digits that represents the numeric month. For example, |
|
Narrow month name. For example, |
|
Two-digit numeric month, zero-padded if necessary. For example, |
|
Wide month name. For example, |
To customize the month format in a string representation of a Date, use month(_:). The following example shows a variety of Date.FormatStyle.Symbol.Month format styles applied to a date.
let meetingDate = Date() // Feb 9, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().month(.abbreviated)) // Feb
meetingDate.formatted(Date.FormatStyle().month(.narrow)) // F
meetingDate.formatted(Date.FormatStyle().month(.defaultDigits)) // 2
meetingDate.formatted(Date.FormatStyle().month(.twoDigits)) // 02
meetingDate.formatted(Date.FormatStyle().month(.wide)) // February
meetingDate.formatted(Date.FormatStyle().month()) // Feb
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.MonthAbbreviated month name. For example, “Sep”.static var defaultDigits: Date.FormatStyle.Symbol.MonthMinimum number of digits that shows the numeric month. Intended to be used in conjunction withDay.defaultDigits. For example,9,12.static var narrow: Date.FormatStyle.Symbol.MonthNarrow month name. For example, “S”.static let omitted: Date.FormatStyle.Symbol.MonthThe option for not including the symbol in the formatted output.static var twoDigits: Date.FormatStyle.Symbol.Month2 digits, zero pad if needed. For example,09,12.static var wide: Date.FormatStyle.Symbol.MonthWide month name. For example, “September”.
Relationships
Conforms To
Swift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype