Date.FormatStyle.Symbol.DayOfYear
A type that specifies the format for the day of the year in a date format style.
Declaration
struct DayOfYearOverview
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
Modifying a Day of Year Value
Comparing Day of Year Values
Type Properties
See Also
Modifying Date Style Format Symbols
Date.FormatStyle.Symbol.CyclicYearDate.FormatStyle.Symbol.DayDate.FormatStyle.Symbol.DayPeriodDate.FormatStyle.Symbol.EraDate.FormatStyle.Symbol.HourDate.FormatStyle.Symbol.MinuteDate.FormatStyle.Symbol.MonthDate.FormatStyle.Symbol.QuarterDate.FormatStyle.Symbol.SecondDate.FormatStyle.Symbol.SecondFractionDate.FormatStyle.Symbol.StandaloneMonthDate.FormatStyle.Symbol.StandaloneQuarterDate.FormatStyle.Symbol.StandaloneWeekdayDate.FormatStyle.Symbol.TimeZoneDate.FormatStyle.Symbol.VerbatimHour