@@ -17,7 +17,8 @@ const (
17
17
stdNumMonth // "1"
18
18
stdZeroMonth // "01"
19
19
stdLongWeekDay // "Monday"
20
- stdNumWeekDay // numerical week representation (0 - Sunday ~ 6 - Saturday)
20
+ stdZeroBasedNumWeekDay // numerical week representation (0 - Sunday ~ 6 - Saturday)
21
+ stdNumWeekDay // numerical week representation (1 - Monday ~ 7- Sunday)
21
22
stdWeekDay // "Mon"
22
23
stdDay // "2"
23
24
stdUnderDay // "_2"
@@ -137,8 +138,14 @@ func AppendFormat(b []byte, t time.Time, layout string) []byte {
137
138
case stdLongWeekDay :
138
139
s := absWeekday (abs ).String ()
139
140
b = append (b , s ... )
141
+ case stdZeroBasedNumWeekDay :
142
+ w := int (absWeekday (abs ))
143
+ b = appendInt (b , w , 0 )
140
144
case stdNumWeekDay :
141
145
w := int (absWeekday (abs ))
146
+ if w == 0 {
147
+ w = 7
148
+ }
142
149
b = appendInt (b , w , 0 )
143
150
case stdDay :
144
151
b = appendInt (b , day , 0 )
@@ -242,7 +249,7 @@ func nextStdChunk(layout string) (prefix string, std int, suffix string) {
242
249
return layout [0 :specPos ], stdMonth , layout [i + 1 :]
243
250
case 'B' : // January
244
251
return layout [0 :specPos ], stdLongMonth , layout [i + 1 :]
245
- case 'c' : // "Mon Jan _2 15:04:05 2006"
252
+ case 'c' : // "Mon Jan _2 15:04:05 2006" (assumes "C" locale)
246
253
return layout [0 :specPos ], stdYield , "%a %b %e %H:%M:%S %Y" + layout [i + 1 :]
247
254
case 'C' : // 20
248
255
return layout [0 :specPos ], stdFirstTwoDigitYear , layout [i + 1 :]
@@ -287,18 +294,20 @@ func nextStdChunk(layout string) (prefix string, std int, suffix string) {
287
294
return layout [0 :specPos ] + "\t " , stdYield , layout [i + 1 :]
288
295
case 'T' : // %H:%M:%S
289
296
return layout [0 :specPos ], stdYield , "%H:%M:%S" + layout [i + 1 :]
290
- // case 'u': // TODO ISO8601 weekday
291
- // return layout[0:specPos], stdNumWeekDay, layout[i+1:]
297
+ case 'u' : // weekday as a decimal number, where Monday is 1
298
+ return layout [0 :specPos ], stdNumWeekDay , layout [i + 1 :]
292
299
case 'U' :
293
300
// TODO week of the year as a decimal number (Sunday is the first day of the week)
294
301
case 'V' :
295
302
return layout [0 :specPos ], stdISO8601Week , layout [i + 1 :]
296
303
case 'w' :
297
- return layout [0 :specPos ], stdNumWeekDay , layout [i + 1 :]
304
+ return layout [0 :specPos ], stdZeroBasedNumWeekDay , layout [i + 1 :]
298
305
case 'W' :
299
306
// TODO: week of the year as a decimal number (Monday is the first day of the week)
300
- //case 'x': // locale depended, not supported
301
- //case 'X': // locale depended, not supported
307
+ case 'x' : // locale depended date representation (assumes "C" locale)
308
+ return layout [0 :specPos ], stdYield , "%m/%d/%y" + layout [i + 1 :]
309
+ case 'X' : // locale depended time representation (assumes "C" locale)
310
+ return layout [0 :specPos ], stdYield , "%H:%M:%S" + layout [i + 1 :]
302
311
case 'y' :
303
312
return layout [0 :specPos ], stdYear , layout [i + 1 :]
304
313
case 'Y' :
0 commit comments