Calendar and DateComponents
Do date arithmetic across calendars.
Calendar and DateComponents
A Calendar interprets a Date into human units like year, month, and day. DateComponents holds those broken-out values.
The Current Calendar
Calendar.current reflects the user's settings. It is the gateway between raw Date instants and named fields.
import Foundation
let cal = Calendar.current
print("Calendar identifier: \(cal.identifier)")All lessons in this course
- The Date Type and Time Intervals
- Calendar and DateComponents
- Formatting Dates
- Time Zones and Locales