A type that specifies the format for the day of the year in a date format style.
The type ``Date/FormatStyle/Symbol/DayOfYear`` includes static factory variables that create custom ``Date/FormatStyle/Symbol/DayOfYear`` objects:
|Factory variable|Description|
|---|---|
| ``defaultDigits`` | The minimum number of digits that represents the full day of the year. For example, `1`, `18`, `317`. |
| ``threeDigits`` | Three-digit numeric day of the year, zero-padded if necessary. For example, `001`, `018`, `317`. |
| ``twoDigits`` | Two-digit numeric day of the year, zero-padded if necessary. This format has no effect on three-digit values. For example, `01`, `18`, `317`. |
To customize the day format in a string representation of a `Date`, use ``Date/FormatStyle/dayOfYear(_:)``. The following example shows a variety of ``Date/FormatStyle/Symbol/DayOfYear`` formats applied to a date.
```swift
let meetingDate = Date() // Feb 9, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().dayOfYear(.defaultDigits)) // 40
meetingDate.formatted(Date.FormatStyle().dayOfYear(.twoDigits)) // 40
meetingDate.formatted(Date.FormatStyle().dayOfYear(.threeDigits)) // 040
meetingDate.formatted(Date.FormatStyle().dayOfYear()) // 40
```
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 (4)
get · iOS 15.0+
threeDigits
TypeScript
static get threeDigits(): Date_FormatStyle_Symbol_DayOfYear
Swift declaration
static var threeDigits: Date.FormatStyle.Symbol.DayOfYear { get }
Three-digit day of year, with zero-padding as necessary. For example, `007`, `033`, `345`.
get · iOS 15.0+
defaultDigits
TypeScript
static get defaultDigits(): Date_FormatStyle_Symbol_DayOfYear
Swift declaration
static var defaultDigits: Date.FormatStyle.Symbol.DayOfYear { get }
Minimum number of digits that shows the full numeric day of year. For example, `7`, `33`, `345`.
get · iOS 18.0+
omitted
TypeScript
static get omitted(): Date_FormatStyle_Symbol_DayOfYear
Swift declaration
static let omitted: Date.FormatStyle.Symbol.DayOfYear
The option for not including the symbol in the formatted output.
get · iOS 15.0+
twoDigits
TypeScript
static get twoDigits(): Date_FormatStyle_Symbol_DayOfYear
Swift declaration
static var twoDigits: Date.FormatStyle.Symbol.DayOfYear { get }
Two-digit day of year, with zero-padding as necessary. For example, `07`, `33`, `345`.