-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrangeInterface.go
40 lines (35 loc) · 1.06 KB
/
rangeInterface.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
package datetime
// RangeStart start bracket
type RangeStart string
// RangeEnd end bracket
type RangeEnd string
var (
// RangeStartStrict can not be equal
RangeStartStrict RangeStart = "["
// RangeStartOptional can be equal
RangeStartOptional RangeStart = "("
// RangeEndStrict can not be equal
RangeEndStrict RangeEnd = "]"
// RangeEndOptional can be equal
RangeEndOptional RangeEnd = ")"
)
const (
YearRegexp = `(\d+)`
MonthRegexp = `(0[1-9]|1[0-2])`
DayRegexp = `(0[1-9]|[12][0-9]|3[01])`
HourRegexp = `(0[0-9]|1[0-9]|2[0-3])`
MinuteRegexp = `[0-5][0-9]`
SecondRegexp = `[0-5][0-9]`
DateRegexp = YearRegexp + `-` + MonthRegexp + `-` + DayRegexp
TimeRegexp = `(` + HourRegexp + `):(` + MinuteRegexp + `):(` + SecondRegexp + `)`
DateTimeRegexp = `((` + DateRegexp + `) (` + TimeRegexp + `))`
RangeRegexp = `^([\[\(])` + DateTimeRegexp + `?\s*,\s*` + DateTimeRegexp + `?([\]\)])$`
)
type RangeInterface interface {
Start() RangeStart
End() RangeEnd
From() ValueInterface
To() ValueInterface
String() string
Is(value any) bool
}