DateComponents encapsulates the components of a date in an extendable, structured manner.
It is used to specify a date by providing the temporal components that make up a date and time in a particular calendar: hour, minutes, seconds, day, month, year, and so on. It can also be used to specify a duration of time, for example, 5 hours and 16 minutes. A
DateComponents is not required to define all the component fields.
When a new instance of
DateComponents is created, the date components are set to
Citizens in Foundation
A type with a customized textual representation suitable for debugging purposes.
A type that explicitly supplies its own mirror.
A type with a customized textual representation.
A type that can decode itself from an external representation.
A type that can encode itself to an external representation.
A type that can be compared for value equality.
A type that can be hashed into a
Hasherto produce an integer hash value.
Decorates types which are backed by a Foundation reference type.
init(calendar: Calendar?, timeZone: TimeZone?, era: Int?, year: Int?, month: Int?, day: Int?, hour: Int?, minute: Int?, second: Int?, nanosecond: Int?, weekday: Int?, weekdayOrdinal: Int?, quarter: Int?, weekOfMonth: Int?, weekOfYear: Int?, yearForWeekOfYear: Int?
DateComponents, optionally specifying values for its fields.
var calendar: Calendar?
Calendarused to interpret the other values in this structure.
var customMirror: Mirror
var date: Date?
Datecalculated from the current components using the
var day: Int?
A day or count of days.
var debugDescription: String
var description: String
var era: Int?
An era or count of eras.
var hour: Int?
An hour or count of hours.
var isLeapMonth: Bool?
Set to true if these components represent a leap month.
var isValidDate: Bool
Returns true if the combination of properties which have been set in the receiver is a date which exists in the
var minute: Int?
A minute or count of minutes.
var month: Int?
A month or count of months.
var nanosecond: Int?
A nanosecond or count of nanoseconds.
var quarter: Int?
A quarter or count of quarters.
var second: Int?
A second or count of seconds.
var timeZone: TimeZone?
A time zone.
var weekOfMonth: Int?
A week of the month or a count of weeks of the month.
var weekOfYear: Int?
A week of the year or count of the weeks of the year.
var weekday: Int?
A weekday or count of weekdays.
var weekdayOrdinal: Int?
A weekday ordinal or count of weekday ordinals. Weekday ordinal units represent the position of the weekday within the next larger calendar unit, such as the month. For example, 2 is the weekday ordinal unit for the second Friday of the month.///
var year: Int?
A year or count of years.
var yearForWeekOfYear: Int?
The ISO 8601 week-numbering year of the receiver.
static func == (DateComponents, DateComponents
) -> Bool
func encode(to: Encoder
func hash(into: inout Hasher
func isValidDate(in: Calendar
) -> Bool
Returns true if the combination of properties which have been set in the receiver is a date which exists in the specified
?, for: Calendar.Component)
Set the value of one of the properties, using an enumeration value instead of a property name.
func value(for: Calendar.Component
) -> Int?
Returns the value of one of the properties, using an enumeration value instead of a property name.