-
Notifications
You must be signed in to change notification settings - Fork 0
/
definitions.go
109 lines (98 loc) · 4.03 KB
/
definitions.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package weeks
import (
"time"
)
// ISO8601 is a week definition that follows the ISO 8601 "week date" standard.See
// https://en.wikipedia.org/wiki/ISO_week_date for more information.
var ISO8601 = Definition{
FirstDayOfWeek: time.Monday,
Numbering: StartAtOne,
FirstFullWeekStrategy: WeekContainingFirstOccurrenceOfWeekday(time.Monday, time.Thursday),
}
// MySQL has 8 different week definitions.
//
// Mode First day of week Range Week 1 is the first week
// 0 Sunday 0-53 with a Sunday in this year
// 1 Monday 0-53 with 4 or more days this year
// 2 Sunday 1-53 with a Sunday in this year
// 3 Monday 1-53 with 4 or more days this year
// 4 Sunday 0-53 with 4 or more days this year
// 5 Monday 0-53 with a Monday in this year
// 6 Sunday 1-53 with 4 or more days this year
// 7 Monday 1-53 with a Monday in this year
//
// See https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_week
var (
// MySQLMode0 is a week definition that conform to MySQL mode 0.
//
// Mode First day of week Range Week 1 is the first week
// 0 Sunday 0-53 with a Sunday in this year
MySQLMode0 = Definition{
FirstDayOfWeek: time.Sunday,
Numbering: PartialWeekZero,
FirstFullWeekStrategy: WeekContainingFirstOccurrenceOfWeekday(time.Sunday, time.Sunday),
}
// MySQLMode1 is a week definition that conform to MySQL mode 1.
//
// Mode First day of week Range Week 1 is the first week
// 1 Monday 0-53 with 4 or more days this year
MySQLMode1 = Definition{
FirstDayOfWeek: time.Monday,
Numbering: PartialWeekZero,
FirstFullWeekStrategy: FirstWeekWithNDays(time.Monday, 4),
}
// MySQLMode2 is a week definition that conform to MySQL mode 2.
//
// Mode First day of week Range Week 1 is the first week
// 2 Sunday 1-53 with a Sunday in this year
MySQLMode2 = Definition{
FirstDayOfWeek: time.Sunday,
Numbering: StartAtOne,
FirstFullWeekStrategy: WeekContainingFirstOccurrenceOfWeekday(time.Sunday, time.Sunday),
}
// MySQLMode3 is a week definition that conform to MySQL mode 3.
//
// Mode First day of week Range Week 1 is the first week
// 3 Monday 1-53 with 4 or more days this year
MySQLMode3 = Definition{
FirstDayOfWeek: time.Monday,
Numbering: StartAtOne,
FirstFullWeekStrategy: FirstWeekWithNDays(time.Monday, 4),
}
// MySQLMode4 is a week definition that conform to MySQL mode 4.
//
// Mode First day of week Range Week 1 is the first week
// 4 Sunday 0-53 with 4 or more days this year
MySQLMode4 = Definition{
FirstDayOfWeek: time.Sunday,
Numbering: PartialWeekZero,
FirstFullWeekStrategy: FirstWeekWithNDays(time.Sunday, 4),
}
// MySQLMode5 is a week definition that conform to MySQL mode 5.
//
// Mode First day of week Range Week 1 is the first week
// 5 Monday 0-53 with a Monday in this year
MySQLMode5 = Definition{
FirstDayOfWeek: time.Monday,
Numbering: PartialWeekZero,
FirstFullWeekStrategy: WeekContainingFirstOccurrenceOfWeekday(time.Monday, time.Monday),
}
// MySQLMode6 is a week definition that conform to MySQL mode 6.
//
// Mode First day of week Range Week 1 is the first week
// 6 Sunday 1-53 with 4 or more days this year
MySQLMode6 = Definition{
FirstDayOfWeek: time.Sunday,
Numbering: StartAtOne,
FirstFullWeekStrategy: FirstWeekWithNDays(time.Sunday, 4),
}
// MySQLMode7 is a week definition that conform to MySQL mode 7.
//
// Mode First day of week Range Week 1 is the first week
// 7 Monday 1-53 with a Monday in this year
MySQLMode7 = Definition{
FirstDayOfWeek: time.Monday,
Numbering: StartAtOne,
FirstFullWeekStrategy: WeekContainingFirstOccurrenceOfWeekday(time.Monday, time.Monday),
}
)