Instance Method

isDateInWeekend(_:)

Indicates whether a given date falls within a weekend period, as defined by the calendar and the calendar's locale.

Declaration

func isDateInWeekend(_ date: Date) -> Bool

Parameters

date

The date for which to perform the calculation.

Return Value

true if the given date is within a weekend period, otherwise false.

Discussion

If the date does fall within a weekend, you can use the range(ofWeekendStart:interval:containing:) method to determine the start date of that weekend period. Otherwise, you can use the nextWeekendStart(_:interval:options:after:) method to determine the start date of the next or previous weekend.

See Also

Comparing Dates

func compare(Date, to: Date, toUnitGranularity: NSCalendar.Unit)

Indicates the ordering of two given dates based on their components down to a given unit granularity.

func isDate(Date, equalTo: Date, toUnitGranularity: NSCalendar.Unit)

Indicates whether two dates are equal to a given unit of granularity.

func isDate(Date, inSameDayAs: Date)

Indicates whether two dates are in the same day.

func isDateInToday(Date)

Indicates whether the given date is in “today.”

func isDateInTomorrow(Date)

Indicates whether the given date is in “tomorrow.”

func isDateInYesterday(Date)

Indicates whether the given date is in “yesterday.”