Structure
Date.FormatStyle.Symbol.Quarter
struct Quarter
Overview
The type Date.FormatStyle.Symbol.Quarter includes static factory variables that create custom Date.FormatStyle.Symbol.Quarter objects:
Factory variable |
Description |
|---|---|
Abbreviated quarter name. For example, |
|
Minimum number of digits that represents the numeric quarter. For example, |
|
One-digit numeric quarter. For example, |
|
Two-digit numeric quarter, zero-padded if necessary. For example, |
|
Wide quarter name. For example, |
To customize the month format in a string representation of a Date, use quarter(_:). The following example shows a variety of Date.FormatStyle.Symbol.Quarter format styles applied to a date.
let meetingDate = Date() // Oct 7, 2020 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().quarter(.abbreviated)) // Q4
meetingDate.formatted(Date.FormatStyle().quarter(.narrow)) // 4th quarter
meetingDate.formatted(Date.FormatStyle().quarter(.oneDigit)) // 4
meetingDate.formatted(Date.FormatStyle().quarter(.twoDigits)) // 04
meetingDate.formatted(Date.FormatStyle().quarter(.wide)) // 4th quarter
meetingDate.formatted(Date.FormatStyle().quarter()) // Q4
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.QuarterAbbreviated quarter. For exampleQ2.static var narrow: Date.FormatStyle.Symbol.QuarterNarrow quarter. For example2.static let omitted: Date.FormatStyle.Symbol.QuarterThe option for not including the symbol in the formatted output.static var oneDigit: Date.FormatStyle.Symbol.QuarterNumeric: one digit quarter. For example2.static var twoDigits: Date.FormatStyle.Symbol.QuarterNumeric: two digits with zero padding. For example02.static var wide: Date.FormatStyle.Symbol.QuarterThe quarter spelled out in full, for example2nd quarter.
Relationships
Conforms To
Swift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype