-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_test.go
48 lines (41 loc) · 1.13 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package schedparser_test
import (
"fmt"
. "github.com/noypi/schedparser"
)
func ExampleParseSched() {
// parses a token
token := "every 3 secs from 06:30 to 08:30"
ret := ParseSched(token, func(bytime *SchedRecurByTime, byday *SchedRecurByDay) {
// do something
})
fmt.Println(token, ret)
// RecurByTime = every decimal_digit (hrs|mins|secs) ["from" time "to" time] .
// RecurByDay = (every|ordinal) Days ["of" (Months)] (time) .
// VALID input examples
// "every 21 hrs"
// "every 3 secs from 06:30 to 08:30"
// "every 05 mins from 06:30 to 09:30"
// "every monday 05:30"
// "every mon 05:30"
// "every wed 15:40"
// "every sat 05:10"
// "every tue of january 17:23"
// "1st thu of sept 17:23"
// "321st sat of dec 17:23"
// "343rd sun of oct 17:23"
// "313th sun of feb 17:23"
// "312th sun of feb 17:23"
// "232nd sun 17:23"
// "232nd mon,sun 17:23"
// "312th sun of feb,jan,mar 17:23"
//
// INVALID input examples:
// "every tuesday 25:30"
// "every friday 24:70"
// "0th thu of sept 17:23"
// "11st thu of january 17:23"
// "211st thu of january 17:23"
// "321rd sat of dec 17:23"
// "313rd sun of oct 17:23"
}