用于处理日历日期重复规则的 Go 库。
Go library for working with recurrence rules for calendar dates. The rrule module offers a complete implementation of the recurrence rules documented in the iCalendar RFC. It is a partial port of the rrule module from the excellent python-dateutil library.
……func ExampleStrToRRule() {
// Compatible with old DTSTART
r, _ := rrule.StrToRRule("FREQ=DAILY;DTSTART=20060101T150405Z;COUNT=5")
fmt.Println(r.OrigOptions.RRuleString())
// FREQ=DAILY;COUNT=5
fmt.Println(r.OrigOptions.String())
// DTSTART:20060101T150405Z
// RRULE:FREQ=DAILY;COUNT=5
fmt.Println(r.String())
// DTSTART:20060101T150405Z
// RRULE:FREQ=DAILY;COUNT=5
printTimeSlice(r.All())
// 2006-01-01 15:04:05 +0000 UTC
// 2006-01-02 15:04:05 +0000 UTC
// 2006-01-03 15:04:05 +0000 UTC
// 2006-01-04 15:04:05 +0000 UTC
// 2006-01-05 15:04:05 +0000 UTC
}func ExampleStrToRRuleSet() {
s, _ := rrule.StrToRRuleSet("DTSTART:20060101T150405Z\nRRULE:FREQ=DAILY;COUNT=5\nEXDATE:20060102T150405Z")
fmt.Println(s.String())
// DTSTART:20060101T150405Z
// RRULE:FREQ=DAILY;COUNT=5
// EXDATE:20060102T150405Z
printTimeSlice(s.All())
// 2006-01-01 15:04:05 +0000 UTC
// 2006-01-03 15:04:05 +0000 UTC
// 2006-01-04 15:04:05 +0000 UTC
// 2006-01-05 15:04:05 +0000 UTC
}For more examples see python-dateutil documentation.
Gear is licensed under the MIT license. Copyright © 2017-2023 Teambition.
暂无开放 Issues,或尚未同步最近议题。