Instance Method

component(_:from:)

Returns the value for one component of a date.

Declaration

func component(_ component: Calendar.Component, from date: Date) -> Int

Parameters

component

The component to calculate.

date

The date to use.

Return Value

The value for the component.

See Also

Extracting Components

func date(Date, matchesComponents: DateComponents)

Determines if the date has all of the specified date components.

func dateComponents(Set<Calendar.Component>, from: Date)

Returns all the date components of a date, using the calendar time zone.

func dateComponents(Set<Calendar.Component>, from: DateComponents, to: DateComponents)

Returns the difference between two dates specified as DateComponents.

func dateComponents(in: TimeZone, from: Date)

Returns all the date components of a date, as if in a given time zone (instead of the Calendar time zone).

enum Calendar.Component

An enumeration for the various components of a calendar date.