Skip to content

Instance Method

nextWeekend(startingAfter:direction:)

iOS 10.0+ iPadOS 10.0+ Mac Catalyst 10.0+ macOS 10.12+ tvOS 10.0+ watchOS 3.0+
Returns a DateInterval of the next weekend, which starts strictly after the given date.
func nextWeekend(startingAfter date: Date, direction: Calendar.SearchDirection = .forward) -> DateInterval?

Parameters

date

The date at which to begin the search.

direction

Which direction in time to search. The default value is .forward.

Return Value

A DateInterval, or nil if weekends do not exist in the specific calendar or locale.

Discussion

If direction is .backward, then finds the previous weekend range strictly before the given date.

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.