interval

package
v1.8.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package interval defines the Interval data type, which represents an algorithmically-defined series of moments in time.

Package interval defines the Interval data type, which represents an algorithmically-defined series of moments in time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interval

type Interval interface {
	// Match returns true if the Interval contains the specified time.
	// Seconds and Nanoseconds are ignored.
	Match(time.Time) bool
}

An Interval represents an algorithmically-defined series of moments in time, to one-minute granularity.

func Parse

func Parse(s string) Interval

Parse parses a string representing an Interval and returns that Interval. If the string cannot be parsed as a valid Interval, ParseInterval returns nil. The string form of an Interval has the following syntax (entirely case-insensitive):

interval = real-interval
         | "NEVER"

real-interval = simple-interval "AND" simple-interval
              | simple-interval "OR" simple-interval
              | simple-interval

simple-interval = "NOT" positive-interval
                | positive-interval

positive-interval = "(" real-interval ")"
                  | interval-term { interval-term }

interval-term = keyword "=" values

keyword = "YEAR" | "MONTH" | "WEEKDAY" | "DAY" | "HOUR" | "MINUTE"

values = value
       | value "-" value
       | value "," values

value = integer   /* for keywords other than WEEKDAY */
      | month     /* for keyword MONTH only */
      | weekday   /* for keyword WEEKDAY only */

month = /* any unambiguous prefix of a month name */

weekday = /* any unambiguous prefix of a weekday name */
        | "WEDS"

Semantically, an interval comprises all moments in time (to one-minute granularity) that satisfy all of the interval terms in the interval, with ANDs, ORs, NOTs, and parentheses interpreted as one would expect. The interval "NEVER" has no moments in time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL