OpeningHours

public struct OpeningHours : Hashable

Defines the OpeningHours of a POI.

  • Creates a new OpeningHours.

    Declaration

    Swift

    public init(mode: OpeningHoursMode, timeRanges: [DateInterval])

    Parameters

    mode

    describes the scope of timeRanges.

    timeRanges

    A sorted series of UTC date intervals starting from today.

  • Describes the scope of timeRanges. (e.g. the .nextSevenDays mode means that timeRanges property contains the time ranges that cover only that period - 7 days starting from today in the POI local time).

    Declaration

    Swift

    public let mode: OpeningHoursMode
  • A sorted series of UTC date intervals starting from today. To convert to a String use DateIntervalFormatter with a corresponding timeZone.

    Note

    The sequence is sorted with the closest dates first.

    Declaration

    Swift

    public let timeRanges: [DateInterval]
  • Defines if the POI is open at the specified date.

    Throws

    An error if the given date is out of the provided opening hours scope

    Declaration

    Swift

    public func isOpen(at date: Date) throws -> Bool

    Parameters

    date

    specifies the day and time for which opening hours are checked

    Return Value

    true if the POI is open at the given date, false otherwise.

  • Defines the opening hours related to the specific day in the POI local time.

    Throws

    An error if the given date is out of the provided opening hours scope

    Declaration

    Swift

    public func openingHours(for date: Date) throws -> [DateInterval]

    Parameters

    date

    specified the day for which the opening hours returned.

    Return Value

    a sorted series of date interval for the given day in the POI local time