TimeRule

public class TimeRule
extension TimeRule: NativeBase
extension TimeRule: Hashable

Used to indicate a time period of one or more intervals in GDF specification. For example: -*(M3f21h2){M9}(M11f12h2){-M9}+(h15){h2}(h20){h2}, which represents: March 2nd Sunday 02h:00m for 9 months ONLY DURING November 1st Sunday 02h:00m from 9 months ago BUT NOT from 15:00 to 17:00 OR 20:00 to 22:00

The operator * represents reccuring occurrence, + represents a logical OR operation and - represents exclusion meaning, BUT NOT operations.

This example string represents a time period that meets the following criteria:

  • M3f21h2: M3 denotes third month of the year, i.e. March, f2 stands for the second Sunday of the month (as “f” might indicate “first”, “second”, “third”, etc.), 1 stands for the day of the week (1…7, Day of week, Sunday = day 1), and h2 represents the hour of the day (02:00) in 24 hour format.
  • {M9}: This denotes “for 9 months”, with “M9” standing for nine months. The brackets {} indicate a duration.
  • M11f12h2: M11 denotes 11th month of the year, i.e. November, f1 stands for the first Monday of the month, 2 stands for the day of the week (1…7, Day of week, Monday = day 2), and h2 represents the hour of the day (02:00) in 24 hour format.
  • {-M9}: This denotes “9 months ago from the current stated time”, with “-M9” standing for nine months in the past.
  • (h15){h2}(h20){h2}: 15:00 to 17:00 OR 20:00 to 22:00 The brackets {} denotes duration, and the negative sign - represents a past duration.

Note: The time period is a logical AND (&&) combination of two components or points in time and it only applies if a point in time is in both components.

For more advanced examples of TimeRule see here.

  • Creates a new instance of this class.

    Declaration

    Swift

    public init(timeRule: String, timeZoneOffsetSeconds: Int32, dstSpec: String)

    Parameters

    timeRule

    The time rule as a string in ISO 14825 format.

    timeZoneOffsetSeconds

    The time zone offset in seconds for the location where the time rule applies.

    dstSpec

    Day saving time specification, as a string in ISO 14825 format, for the location where the time rule applies.

  • The time rule as a string in ISO 14825 format.

    Declaration

    Swift

    public var timeRuleString: String { get }
  • The time zone offset in seconds for the location where the time rule applies.

    Declaration

    Swift

    public var timeZoneOffsetSeconds: Int32 { get }
  • Day saving time specification, as a string in ISO 14825 format, for the location where the time rule applies.

    Declaration

    Swift

    public var dstSpec: String { get }
  • Declaration

    Swift

    public func appliesTo(dateTime: Date) -> Bool

    Parameters

    dateTime

    date and time that should be used for rule verification.

    Return Value

    true if the time domain rules applies to the given date and time., false - otherwise.