Documentation ¶
Overview ¶
Package recurrence providers calendar recurrence rules in Go.
Basically, implementing the strategy described in Martin Fowler's paper at http://martinfowler.com/apsupp/recurring.pdf. Read it. It's fun.
Index ¶
Constants ¶
const ( Last int = -1 + iota Never First Second Third Fourth Fifth )
Integers representing the natural language expression of dates. (i.e. "First Sunday")
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnySchedule ¶
type AnySchedule struct {
Schedule Schedule
}
AnySchedule acts as a wrapper around...any schedule. Why does this exists? Since the tree of Schedules is an arbitrary relationship of interfaces, we need a struct to *easily* marshal/unmarshal json of the entire schedule hierarchy.
func (AnySchedule) IsOccurring ¶
func (a AnySchedule) IsOccurring(t time.Time) bool
IsOccurring implements the Schedule interface.
func (AnySchedule) MarshalJSON ¶
func (a AnySchedule) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (AnySchedule) Occurrences ¶
func (a AnySchedule) Occurrences(t TimeRange) chan time.Time
Occurrences implements the Schedule interface.
func (*AnySchedule) UnmarshalJSON ¶
func (a *AnySchedule) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type Date ¶
Date is a specific day. Shorthand for Intersection{Year, Month, Day}.
func (Date) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (Date) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Date) Occurrences ¶
Occurrences implements the Schedule interface.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Day ¶
type Day int
A Day specifies a day of the month. (1, 2, 3, ...31)
func (Day) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (Day) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Day) Occurrences ¶
Occurrences implements the Schedule interface.
func (*Day) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Intersection ¶
type Intersection []Schedule
Intersection computes the set intersection of a slice of Schedules.
func OrdinalWeekday ¶
func OrdinalWeekday(i int, w Weekday) Intersection
OrdinalWeekday generates Schedules for natural recurrence patterns such as the "Last Wednesday" or "Second Sunday".
func (Intersection) IsOccurring ¶
func (i Intersection) IsOccurring(t time.Time) bool
IsOccurring implements the Schedule interface.
func (Intersection) MarshalJSON ¶
func (i Intersection) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (Intersection) Occurrences ¶
func (i Intersection) Occurrences(t TimeRange) chan time.Time
Occurrences implements the Schedule interface.
func (*Intersection) UnmarshalJSON ¶
func (i *Intersection) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type Month ¶
A Month represents a month of the year. Just like time.Month.
const ( January Month = 1 + iota February March April May June July August September October November December )
The months of the year
func (Month) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (Month) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Month) Occurrences ¶
Occurrences implements the Schedule interface.
func (*Month) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Schedule ¶
The Schedule interface is the foundation of the recurrence package. Types satisfying the Schedule interface can be used to determine if a time.Time occurs in the Schedule, and generate time.Times satisfying the Schedule.
func ScheduleUnmarshalJSON ¶
ScheduleUnmarshalJSON unmarshals bytes representing any arbitrary relationship of schedules.
type TimeRange ¶
A TimeRange represents a range of time, with a start and an end.
func MonthRange ¶
MonthRange generates a TimeRange representing a specific month.
func NewTimeRange ¶
NewTimeRange let's you create a new TimeRange from the time format "2006-01-02"
func (TimeRange) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (TimeRange) Occurrences ¶
Occurrences implements the Schedule interface.
func (*TimeRange) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Union ¶
type Union []Schedule
Union computes the set union of a slice of Schedules.
func (Union) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (Union) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Union) Occurrences ¶
Occurrences implements the Schedule interface.
func (*Union) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Week ¶
type Week int
A Week represents a week of the month. This is most useful in combination with other entities satisfying the Schedule interface.
func (Week) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (Week) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Week) Occurrences ¶
Occurrences implements the Schedule interface.
func (*Week) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Weekday ¶
A Weekday represents a day of the week. (Sunday, Monday, ...Saturday)
The days of the week
func (Weekday) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (Weekday) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Weekday) Occurrences ¶
Occurrences implements the Schedule interface.
func (*Weekday) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Year ¶
type Year int
Year represents a year.
func (Year) IsOccurring ¶
IsOccurring implements the Schedule interface.
func (Year) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Year) Occurrences ¶
Occurrences implements the Schedule interface.