Structure
Date.FormatStyle.Symbol.Week
struct Week
Overview
The type Date.FormatStyle.Symbol.Week includes static factory variables that create custom Date.FormatStyle.Symbol.Week objects:
Factory variable |
Description |
|---|---|
The minimum number of digits that represents the full numeric week. For example, |
|
Two-digit numeric week, zero-padded if necessary. For example, |
|
The numeric week of the month. For example, |
To customize the week format in a string representation of a Date, use week(_:). The following example shows a variety of Date.FormatStyle.Symbol.Week format styles applied to a date.
let meetingDate = Date() // May 3, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().week(.defaultDigits)) // 19
meetingDate.formatted(Date.FormatStyle().week(.twoDigits)) // 19
meetingDate.formatted(Date.FormatStyle().week(.weekOfMonth)) // 2
meetingDate.formatted(Date.FormatStyle().week()) // 19
An incomplete week at the start of a month is week of the month 1. 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.WeekNumeric week of year. For example,8,27.static let omitted: Date.FormatStyle.Symbol.WeekThe option for not including the symbol in the formatted output.static var twoDigits: Date.FormatStyle.Symbol.WeekTwo-digit numeric week of year, zero padded as necessary. For example,08,27.static var weekOfMonth: Date.FormatStyle.Symbol.WeekOne-digit numeric week of month, starting from 1. For example,1.
Relationships
Conforms To
Swift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype