ScheduleDefinition

open class ScheduleDefinition

Allows selecting date-time intervals by specifying week and day intervals, and optionally excluding time intervals returned by a specific function.

  • Initializes a schedule definition, optionally with a client provider object to return the week interval, day interval, and excluded intervals within a specific interval passed to a function of the object upon request.

    Declaration

    Swift

    public init(provider: ScheduleDefinitionProvider? = nil)
  • Selects an interval between two days of week to consider for each week.

    Declaration

    Swift

    open var weekInterval: WeekRange { get }
  • Selects an interval between two times of day to consider for each selected day.

    Declaration

    Swift

    open var dayInterval: DayRange { get }
  • Returns the date-time intervals to be considered as excluded from the selected time for the value and towards the limit received as arguments. Only the interval(s) that contain or are closest to the input time towards the specified limit need to actually be returned. For any partition of the input interval, the aggregating results of the function applied to its individual parts should correspond to the result of the function applied to the entire interval.

    Declaration

    Swift

    open func excludedIntervals(for time: Time, towards limit: Time) -> [TimeRange]
  • Offers optimizations when excluded intervals aren’t possible.

    Declaration

    Swift

    open var hasExcludedIntervals: Bool { get }
  • Optional external data provider for week, day, and excluded intervals to use upon scheduling.

    Declaration

    Swift

    public weak var provider: ScheduleDefinitionProvider?
  • Returns the next available date-time for the specified value, or the value itself if it is an appropriate start time, according to the scheduling logic.

    Declaration

    Swift

    public func nextTime(for time: Time) -> Time
  • Returns the previous available date-time for the specified value, or the value itself if it is an appropriate finish time, according to the scheduling logic.

    Declaration

    Swift

    public func previousTime(for time: Time) -> Time
  • Returns the next not available date-time for the specified value, or the value itself if it is an appropriate finish time, according to the scheduling logic.

    Declaration

    Swift

    public func nextTimeout(for time: Time) -> Time
  • Returns the previous not available date-time for the specified value, or the value itself if it is an appropriate start time, according to the scheduling logic.

    Declaration

    Swift

    public func previousTimeout(for time: Time) -> Time
  • Returns the duration between two date-time values according to the scheduling logic (in seconds).

    Declaration

    Swift

    public func duration(from start: Time, to finish: Time) -> TimeInterval
  • Returns the duration between two date-time values according to the scheduling logic, in a specific time unit.

    Declaration

    Swift

    public func duration(from start: Time, to finish: Time, in unit: TimeUnit) -> Double
  • Returns the duration of a date-time interval according to the scheduling logic (in seconds).

    Declaration

    Swift

    public func duration(of interval: TimeRange) -> TimeInterval
  • Returns the duration of a date-time interval according to the scheduling logic, in a specific time unit.

    Declaration

    Swift

    public func duration(of interval: TimeRange, in unit: TimeUnit) -> Double
  • Returns the finish date-time for an interval starting at a specified date-time and that would last for a specified duration (in seconds), according to the scheduling logic.

    Declaration

    Swift

    public func finish(from start: Time, for duration: TimeInterval) -> Time
  • Returns the finish date-time for an interval starting at a specified date-time and that would last for a specified duration (in a specific time unit), according to the scheduling logic.

    Declaration

    Swift

    public func finish(from start: Time, for duration: Double, in unit: TimeUnit) -> Time
  • Returns the start date-time for an interval finishing at a specified date-time and that would last for a specified duration (in seconds), according to the scheduling logic.

    Declaration

    Swift

    public func start(to finish: Time, for duration: TimeInterval) -> Time
  • Returns the start date-time for an interval finishing at a specified date-time and that would last for a specified duration (in a specific time unit), according to the scheduling logic.

    Declaration

    Swift

    public func start(to finish: Time, for duration: Double, in unit: TimeUnit) -> Time
  • Returns the value resulting by rounding the specified date-time on the specified scale (granularity).

    Declaration

    Swift

    public func rounding(_ time: Time, on scale: TimeScale) -> Time
  • Determines available date-time intervals in a specified interval according to the scheduling logic.

    Declaration

    Swift

    public func times(in interval: TimeRange) -> [TimeRange]
  • Determines not available date-time intervals in a specified interval according to the scheduling logic.

    Declaration

    Swift

    public func timeouts(in interval: TimeRange) -> [TimeRange]
  • Returns the number of scheduled hours per day considering the day interval definition (and disregarding excluded intervals).

    Declaration

    Swift

    public var hoursPerDay: Double { get }
  • Returns the number of scheduled days per week considering the week interval definition (and disregarding excluded intervals).

    Declaration

    Swift

    public var daysPerWeek: Int { get }
  • Returns the number of scheduled hours per week considering the day and week interval definitions (and disregarding excluded intervals).

    Declaration

    Swift

    public var hoursPerWeek: Double { get }
  • Returns the scheduled duration of a day considering the day interval definition (and disregarding excluded intervals).

    Declaration

    Swift

    public var dayDuration: Double { get }
  • Returns the scheduled duration of a week considering the day and week interval definitions (and disregarding excluded intervals).

    Declaration

    Swift

    public var weekDuration: Double { get }
  • Indicates whether all day time is scheduled (possibly not for all week days, though), considering the day interval definition (and disregarding excluded intervals).

    Declaration

    Swift

    public var isFullDay: Bool { get }
  • Indicates whether all week days are scheduled (possibly not all day time, though), considering the week interval definition (and disregarding excluded intervals).

    Declaration

    Swift

    public var isFullWeek: Bool { get }
  • Indicates whether all day time of all week days is scheduled, considering the day and week interval definitions (and disregarding excluded intervals).

    Declaration

    Swift

    public var isContinuous: Bool { get }
  • Indicates whether a specified date-time interval is continuously scheduled considering the excluded intervals for that interval (and assuming continuous day and week interval definitions).

    Declaration

    Swift

    public func isContinuous(during interval: TimeRange) -> Bool
  • Returns a schedule object representing the intersection of the current scheduling logic with the specified schedule definition when week and day intervals overlap.

    Declaration

    Swift

    public func intersecting(
        _ definition: ScheduleDefinition) -> ScheduleIntersection?
  • Returns the schedule intersection between the current schedule and the specified definition when applicable or the current schedule itself otherwise.

    Declaration

    Swift

    public func optionallyIntersecting(
        _ definition: ScheduleDefinition?) -> ScheduleDefinition
  • Schedules continuous time (24 hours/day, 7 days/week).

    Declaration

    Swift

    static let continuous: Schedule
  • Schedules time between 8 AM and 4 PM, Monday to Friday (8 hours/day, 5 days/week).

    Declaration

    Swift

    static let standard: Schedule
  • Schedules time between 8 AM and 4 PM for all week days (8 hours/day, 7 days/week).

    Declaration

    Swift

    static let fullWeek: Schedule
  • Schedules continuous time between Monday and Friday (24 hours/day, 5 days/week).

    Declaration

    Swift

    static let fullDay: Schedule