Structure
Date.FormatStyle.Symbol.DayOfYear
struct DayOfYear
Overview
The type Date.FormatStyle.Symbol.DayOfYear includes static factory variables that create custom Date.FormatStyle.Symbol.DayOfYear objects:
Factory variable |
Description |
|---|---|
The minimum number of digits that represents the full day of the year. For example, |
|
Three-digit numeric day of the year, zero-padded if necessary. For example, |
|
Two-digit numeric day of the year, zero-padded if necessary. This format has no effect on three-digit values. For example, |
To customize the day format in a string representation of a Date, use dayOfYear(_:). The following example shows a variety of Date.FormatStyle.Symbol.DayOfYear formats applied to a date.
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.
Topics
Type Properties
static var defaultDigits: Date.FormatStyle.Symbol.DayOfYearMinimum number of digits that shows the full numeric day of year. For example,7,33,345.static let omitted: Date.FormatStyle.Symbol.DayOfYearThe option for not including the symbol in the formatted output.static var threeDigits: Date.FormatStyle.Symbol.DayOfYearThree-digit day of year, with zero-padding as necessary. For example,007,033,345.static var twoDigits: Date.FormatStyle.Symbol.DayOfYearTwo-digit day of year, with zero-padding as necessary. For example,07,33,345.
Relationships
Conforms To
Swift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype