@@ -28,15 +28,40 @@ func TestBeginningOf(t *testing.T) {
28
28
t .Errorf ("BeginningOfDay" )
29
29
}
30
30
31
- if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-17 00:00:00" {
32
- t .Errorf ("BeginningOfWeek" )
33
- }
34
-
35
- FirstDayMonday = true
31
+ WeekStartDay = time .Monday
36
32
if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-18 00:00:00" {
37
33
t .Errorf ("BeginningOfWeek, FirstDayMonday" )
38
34
}
39
- FirstDayMonday = false
35
+
36
+ WeekStartDay = time .Tuesday
37
+ if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-12 00:00:00" {
38
+ t .Errorf ("BeginningOfWeek, FirstDayTuesday" )
39
+ }
40
+
41
+ WeekStartDay = time .Wednesday
42
+ if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-13 00:00:00" {
43
+ t .Errorf ("BeginningOfWeek, FirstDayWednesday" )
44
+ }
45
+
46
+ WeekStartDay = time .Thursday
47
+ if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-14 00:00:00" {
48
+ t .Errorf ("BeginningOfWeek, FirstDayThursday" )
49
+ }
50
+
51
+ WeekStartDay = time .Friday
52
+ if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-15 00:00:00" {
53
+ t .Errorf ("BeginningOfWeek, FirstDayFriday" )
54
+ }
55
+
56
+ WeekStartDay = time .Saturday
57
+ if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-16 00:00:00" {
58
+ t .Errorf ("BeginningOfWeek, FirstDaySaturday" )
59
+ }
60
+
61
+ WeekStartDay = time .Sunday
62
+ if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-17 00:00:00" {
63
+ t .Errorf ("BeginningOfWeek, FirstDaySunday" )
64
+ }
40
65
41
66
if New (n ).BeginningOfMonth ().Format (format ) != "2013-11-01 00:00:00" {
42
67
t .Errorf ("BeginningOfMonth" )
@@ -74,14 +99,39 @@ func TestEndOf(t *testing.T) {
74
99
t .Errorf ("EndOfDay" )
75
100
}
76
101
77
- FirstDayMonday = true
102
+ WeekStartDay = time . Monday
78
103
if New (n ).EndOfWeek ().Format (format ) != "2013-11-24 23:59:59.999999999" {
79
104
t .Errorf ("EndOfWeek, FirstDayMonday" )
80
105
}
81
106
82
- FirstDayMonday = false
107
+ WeekStartDay = time .Tuesday
108
+ if New (n ).EndOfWeek ().Format (format ) != "2013-11-18 23:59:59.999999999" {
109
+ t .Errorf ("EndOfWeek, FirstDayTuesday" )
110
+ }
111
+
112
+ WeekStartDay = time .Wednesday
113
+ if New (n ).EndOfWeek ().Format (format ) != "2013-11-19 23:59:59.999999999" {
114
+ t .Errorf ("EndOfWeek, FirstDayWednesday" )
115
+ }
116
+
117
+ WeekStartDay = time .Thursday
118
+ if New (n ).EndOfWeek ().Format (format ) != "2013-11-20 23:59:59.999999999" {
119
+ t .Errorf ("EndOfWeek, FirstDayThursday" )
120
+ }
121
+
122
+ WeekStartDay = time .Friday
123
+ if New (n ).EndOfWeek ().Format (format ) != "2013-11-21 23:59:59.999999999" {
124
+ t .Errorf ("EndOfWeek, FirstDayFriday" )
125
+ }
126
+
127
+ WeekStartDay = time .Saturday
128
+ if New (n ).EndOfWeek ().Format (format ) != "2013-11-22 23:59:59.999999999" {
129
+ t .Errorf ("EndOfWeek, FirstDaySaturday" )
130
+ }
131
+
132
+ WeekStartDay = time .Sunday
83
133
if New (n ).EndOfWeek ().Format (format ) != "2013-11-23 23:59:59.999999999" {
84
- t .Errorf ("EndOfWeek" )
134
+ t .Errorf ("EndOfWeek, FirstDaySunday " )
85
135
}
86
136
87
137
if New (n ).EndOfMonth ().Format (format ) != "2013-11-30 23:59:59.999999999" {
@@ -143,7 +193,7 @@ func TestMondayAndSunday(t *testing.T) {
143
193
t .Errorf ("BeginningOfWeek, FirstDayMonday" )
144
194
}
145
195
146
- FirstDayMonday = true
196
+ WeekStartDay = time . Monday
147
197
if New (n ).BeginningOfWeek ().Format (format ) != "2013-11-18 00:00:00" {
148
198
t .Errorf ("BeginningOfWeek, FirstDayMonday" )
149
199
}
@@ -250,22 +300,22 @@ func Example() {
250
300
BeginningOfDay () // 2013-11-18 00:00:00 Mon
251
301
BeginningOfWeek () // 2013-11-17 00:00:00 Sun
252
302
253
- FirstDayMonday = true // Set Monday as first day
254
- BeginningOfWeek () // 2013-11-18 00:00:00 Mon
255
- BeginningOfMonth () // 2013-11-01 00:00:00 Fri
256
- BeginningOfQuarter () // 2013-10-01 00:00:00 Tue
257
- BeginningOfYear () // 2013-01-01 00:00:00 Tue
303
+ WeekStartDay = time . Monday // Set Monday as first day
304
+ BeginningOfWeek () // 2013-11-18 00:00:00 Mon
305
+ BeginningOfMonth () // 2013-11-01 00:00:00 Fri
306
+ BeginningOfQuarter () // 2013-10-01 00:00:00 Tue
307
+ BeginningOfYear () // 2013-01-01 00:00:00 Tue
258
308
259
309
EndOfMinute () // 2013-11-18 17:51:59.999999999 Mon
260
310
EndOfHour () // 2013-11-18 17:59:59.999999999 Mon
261
311
EndOfDay () // 2013-11-18 23:59:59.999999999 Mon
262
312
EndOfWeek () // 2013-11-23 23:59:59.999999999 Sat
263
313
264
- FirstDayMonday = true // Set Monday as first day
265
- EndOfWeek () // 2013-11-24 23:59:59.999999999 Sun
266
- EndOfMonth () // 2013-11-30 23:59:59.999999999 Sat
267
- EndOfQuarter () // 2013-12-31 23:59:59.999999999 Tue
268
- EndOfYear () // 2013-12-31 23:59:59.999999999 Tue
314
+ WeekStartDay = time . Monday // Set Monday as first day
315
+ EndOfWeek () // 2013-11-24 23:59:59.999999999 Sun
316
+ EndOfMonth () // 2013-11-30 23:59:59.999999999 Sat
317
+ EndOfQuarter () // 2013-12-31 23:59:59.999999999 Tue
318
+ EndOfYear () // 2013-12-31 23:59:59.999999999 Tue
269
319
270
320
// Use another time
271
321
t := time .Date (2013 , 02 , 18 , 17 , 51 , 49 , 123456789 , time .UTC )
0 commit comments