-
Notifications
You must be signed in to change notification settings - Fork 1
/
context.go
43 lines (39 loc) · 835 Bytes
/
context.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
package tokei
// expressionContext defines the type of expression we're parsing.
type expressionContext int
// Types of ExpressionContext
const (
minuteContext expressionContext = iota
hourContext
dayOfMonthContext
monthContext
dayOfWeekContext
)
// Min gets the min value for the context.
func (ex expressionContext) Min() int {
switch ex {
case minuteContext, hourContext:
return 0
case dayOfWeekContext, monthContext, dayOfMonthContext:
return 1
default:
panic("invalid expression context")
}
}
// Max gets the max value for the context.
func (ex expressionContext) Max() int {
switch ex {
case minuteContext:
return 59
case hourContext:
return 23
case dayOfWeekContext:
return 7
case monthContext:
return 12
case dayOfMonthContext:
return 31
default:
panic("invalid expression context")
}
}