Documentation ¶
Index ¶
- Constants
- Variables
- func StrToDates(str string) (ts []time.Time, err error)
- func StrToDatesInLoc(str string, defaultLoc *time.Location) (ts []time.Time, err error)
- func StrToDtStart(str string, defaultLoc *time.Location) (time.Time, error)
- type Frequency
- type Next
- type ROption
- type RRule
- func (r *RRule) After(dt time.Time, inc bool) time.Time
- func (r *RRule) All() []time.Time
- func (r *RRule) Before(dt time.Time, inc bool) time.Time
- func (r *RRule) Between(after, before time.Time, inc bool) []time.Time
- func (r *RRule) DTStart(dt time.Time)
- func (r *RRule) GetDTStart() time.Time
- func (r *RRule) GetUntil() time.Time
- func (r *RRule) Iterator() Next
- func (r *RRule) String() string
- func (r *RRule) ToText() string
- func (r *RRule) ToTextWithCustomFormatter(formatter TimeFormatter, langs ...string) (string, error)
- func (r *RRule) Until(ut time.Time)
- type Set
- func (set *Set) After(dt time.Time, inc bool) time.Time
- func (set *Set) All() []time.Time
- func (set *Set) Before(dt time.Time, inc bool) time.Time
- func (set *Set) Between(after, before time.Time, inc bool) []time.Time
- func (set *Set) DTStart(dtstart time.Time)
- func (set *Set) ExDate(exdate time.Time)
- func (set *Set) GetDTStart() time.Time
- func (set *Set) GetExDate() []time.Time
- func (set *Set) GetRDate() []time.Time
- func (set *Set) GetRRule() *RRule
- func (set *Set) Iterator() (next func() (time.Time, bool))
- func (set *Set) RDate(rdate time.Time)
- func (set *Set) RRule(rrule *RRule)
- func (set *Set) Recurrence() []string
- func (set *Set) SetExDates(exdates []time.Time)
- func (set *Set) SetRDates(rdates []time.Time)
- func (set *Set) String() string
- type TimeFormatter
- type Weekday
Constants ¶
const ( // DateTimeFormat is date-time format used in iCalendar (RFC 5545) DateTimeFormat = "20060102T150405Z" // LocalDateTimeFormat is a date-time format without Z prefix LocalDateTimeFormat = "20060102T150405" // DateFormat is date format used in iCalendar (RFC 5545) DateFormat = "20060102" )
const (
MAXYEAR = 9999
)
MAXYEAR
Variables ¶
var ( M366MASK []int M365MASK []int MDAY366MASK []int MDAY365MASK []int NMDAY366MASK []int NMDAY365MASK []int WDAYMASK []int M366RANGE = []int{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} M365RANGE = []int{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365} )
Every mask is 7 days longer to handle cross-year weekly periods.
var ( MO = Weekday{/* contains filtered or unexported fields */} TU = Weekday{/* contains filtered or unexported fields */} WE = Weekday{/* contains filtered or unexported fields */} TH = Weekday{/* contains filtered or unexported fields */} FR = Weekday{/* contains filtered or unexported fields */} SA = Weekday{/* contains filtered or unexported fields */} SU = Weekday{/* contains filtered or unexported fields */} )
Weekdays
Functions ¶
func StrToDates ¶
StrToDates is intended to parse RDATE and EXDATE properties supporting only VALUE=DATE-TIME (DATE and PERIOD are not supported). Accepts string with format: "VALUE=DATE-TIME;[TZID=...]:{time},{time},...,{time}" or simply "{time},{time},...{time}" and parses it to array of dates In case no time zone specified in str, when all dates are parsed in UTC
func StrToDatesInLoc ¶
StrToDatesInLoc same as StrToDates but it consideres default location to parse dates in in case no location specified with TZID parameter
Types ¶
type Next ¶
Next is a generator of time.Time. It returns false of Ok if there is no value to generate.
type ROption ¶
type ROption struct { Freq Frequency Dtstart time.Time Interval int Wkst Weekday Count int Until time.Time Bysetpos []int Bymonth []int Bymonthday []int Byyearday []int Byweekno []int Byweekday []Weekday Byhour []int Byminute []int Bysecond []int Byeaster []int }
ROption offers options to construct a RRule instance. For performance, it is strongly recommended providing explicit ROption.Dtstart, which defaults to `time.Now().UTC().Truncate(time.Second)`.
func StrToROption ¶
StrToROption converts string to ROption.
func StrToROptionInLocation ¶
StrToROptionInLocation is same as StrToROption but in case local time is supplied as date-time/date field (ex. UNTIL), it is parsed as a time in a given location (time zone)
func (*ROption) RRuleString ¶
RRuleString returns RRULE string exclude DTSTART
type RRule ¶
RRule offers a small, complete, and very fast, implementation of the recurrence rules documented in the iCalendar RFC, including support for caching of results.
func NewRRuleWithi18n ¶ added in v1.1.0
func StrToRRule ¶
StrToRRule converts string to RRule
func StrToRRuleWithi18n ¶ added in v1.1.0
func (*RRule) After ¶
After returns the first recurrence after the given datetime instance, or time.Time's zero value if no recurrence match. The inc keyword defines what happens if dt is an occurrence. With inc == True, if dt itself is an occurrence, it will be returned. It is only supported second precision.
func (*RRule) All ¶
All returns all occurrences of the RRule. It is only supported second precision.
func (*RRule) Before ¶
Before returns the last recurrence before the given datetime instance, or time.Time's zero value if no recurrence match. The inc keyword defines what happens if dt is an occurrence. With inc == True, if dt itself is an occurrence, it will be returned. It is only supported second precision.
func (*RRule) Between ¶
Between returns all the occurrences of the RRule between after and before. The inc keyword defines what happens if after and/or before are themselves occurrences. With inc == True, they will be included in the list, if they are found in the recurrence set. It is only supported second precision.
func (*RRule) DTStart ¶
DTStart set a new DTSTART for the rule and recalculates the timeset if needed. It will be truncated to second precision. Default to `time.Now().UTC().Truncate(time.Second)`.
func (*RRule) GetDTStart ¶
GetDTStart gets DTSTART time for rrule
func (*RRule) ToTextWithCustomFormatter ¶ added in v1.1.0
func (r *RRule) ToTextWithCustomFormatter(formatter TimeFormatter, langs ...string) (string, error)
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set allows more complex recurrence setups, mixing multiple rules, dates, exclusion rules, and exclusion dates
func StrSliceToRRuleSet ¶
StrSliceToRRuleSet converts given str slice to RRuleSet In case there is a time met in any rule without specified time zone, when it is parsed in UTC (see StrSliceToRRuleSetInLoc)
func StrSliceToRRuleSetInLoc ¶
StrSliceToRRuleSetInLoc is same as StrSliceToRRuleSet, but by default parses local times in specified default location
func StrToRRuleSet ¶
StrToRRuleSet converts string to RRuleSet
func (*Set) After ¶
After returns the first recurrence after the given datetime instance, or time.Time's zero value if no recurrence match. The inc keyword defines what happens if dt is an occurrence. With inc == True, if dt itself is an occurrence, it will be returned. It is only supported second precision.
func (*Set) All ¶
All returns all occurrences of the rrule.Set. It is only supported second precision.
func (*Set) Before ¶
Before Returns the last recurrence before the given datetime instance, or time.Time's zero value if no recurrence match. The inc keyword defines what happens if dt is an occurrence. With inc == True, if dt itself is an occurrence, it will be returned. It is only supported second precision.
func (*Set) Between ¶
Between returns all the occurrences of the rrule between after and before. The inc keyword defines what happens if after and/or before are themselves occurrences. With inc == True, they will be included in the list, if they are found in the recurrence set. It is only supported second precision.
func (*Set) DTStart ¶
DTStart sets dtstart property for set. It will be truncated to second precision.
func (*Set) ExDate ¶
ExDate include the given datetime instance in the recurrence set exclusion list. Dates included that way will not be generated, even if some inclusive rrule or rdate matches them. It will be truncated to second precision.
func (*Set) RDate ¶
RDate include the given datetime instance in the recurrence set generation. It will be truncated to second precision.
func (*Set) RRule ¶
RRule set the RRULE for set. There is the only one RRULE in the set as https://tools.ietf.org/html/rfc5545#appendix-A.1
func (*Set) Recurrence ¶
Recurrence returns a slice of all the recurrence rules for a set
func (*Set) SetExDates ¶
SetExDates sets explicitly excluded dates (exdates) in the set. It will be truncated to second precision.
type TimeFormatter ¶ added in v1.1.0
type Weekday ¶
type Weekday struct {
// contains filtered or unexported fields
}
Weekday specifying the nth weekday. Field N could be positive or negative (like MO(+2) or MO(-3). Not specifying N (0) is the same as specifying +1.