dateIntervalOfWeekend(containing:start:interval:)

Finds the range of the weekend around the given date, and returns the starting date and duration of the weekend via two inout parameters.

iOS
8.0+
macOS
10.10+
tvOS
9.0+
watchOS
2.0+
func dateIntervalOfWeekend(containing date: Date, start: inout Date, interval: inout TimeInterval) -> Bool

Parameters

date

The date at which to start the search.

start

Upon return, the starting date of the weekend if found.

interval

Upon return, the duration of the weekend if found.

Returns

true if a date range could be found, and false if the date is not in a weekend.

Note that a given entire day within a calendar is not necessarily all in a weekend or not; weekends can start in the middle of a day in some calendars and locales.