Contents

DateComponents

A date or time specified in terms of units (such as year, month, day, hour, and minute) to be evaluated in a calendar system and time zone.

Declaration

struct DateComponents

Overview

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 nil.

Topics

Initializing Date Components

Validating a Date

Accessing Months and Years

Accessing Weeks and Days

Accessing Hours and Seconds

Accessing Calendar Components

Using Reference Types

Structures

Initializers

Instance Properties

Instance Methods

Type Aliases

Type Properties

See Also

Calendrical Calculations