@@ -11,6 +11,7 @@ import (
11
11
12
12
const (
13
13
_ = iota
14
+ stdYield // Yielded chunk
14
15
stdLongMonth = iota + stdNeedDate // "January"
15
16
stdMonth // "Jan"
16
17
stdNumMonth // "1"
@@ -96,6 +97,8 @@ func AppendFormat(b []byte, t time.Time, layout string) []byte {
96
97
}
97
98
98
99
switch std & stdMask {
100
+ case stdYield :
101
+ continue
99
102
case stdISO8601WeekYear :
100
103
b = appendInt (b , iso8601WeekYear / 100 , 2 )
101
104
case stdISO8601LongWeekYear :
@@ -176,11 +179,9 @@ func AppendFormat(b []byte, t time.Time, layout string) []byte {
176
179
}
177
180
case stdNumTZ :
178
181
zone := offset / 60 // convert to minutes
179
- absoffset := offset
180
182
if zone < 0 {
181
183
b = append (b , '-' )
182
184
zone = - zone
183
- absoffset = - absoffset
184
185
} else {
185
186
b = append (b , '+' )
186
187
}
@@ -208,7 +209,6 @@ func AppendFormat(b []byte, t time.Time, layout string) []byte {
208
209
}
209
210
}
210
211
return b
211
- return b
212
212
}
213
213
214
214
// nextStdChunk finds the first occurrence of a std string in
@@ -237,7 +237,7 @@ func nextStdChunk(layout string) (prefix string, std int, suffix string) {
237
237
case 'B' : // January
238
238
return layout [0 :specPos ], stdLongMonth , layout [i + 1 :]
239
239
case 'c' : // "Mon Jan _2 15:04:05 2006"
240
- return layout [0 :specPos ], stdMonth , " %e %H:%M:%S %Y" + layout [i + 1 :]
240
+ return layout [0 :specPos ], stdYield , "%a %b %e %H:%M:%S %Y" + layout [i + 1 :]
241
241
case 'C' : // 20
242
242
return layout [0 :specPos ], stdFirstTwoDigitYear , layout [i + 1 :]
243
243
case 'd' : // 02
@@ -267,22 +267,22 @@ func nextStdChunk(layout string) (prefix string, std int, suffix string) {
267
267
case 'M' :
268
268
return layout [0 :specPos ], stdZeroMinute , layout [i + 1 :]
269
269
case 'n' :
270
- // TODO: newline character '\n'
270
+ return layout [ 0 : specPos ] + " \n " , stdYield , layout [ i + 1 :]
271
271
case 'p' :
272
272
return layout [0 :specPos ], stdPM , layout [i + 1 :]
273
273
case 'P' :
274
274
return layout [0 :specPos ], stdpm , layout [i + 1 :]
275
275
case 'r' :
276
276
case 'R' : // %H:%M"
277
- return layout [0 :specPos ], stdHour , ":%M" + layout [i + 1 :]
277
+ return layout [0 :specPos ], stdYield , "%H :%M" + layout [i + 1 :]
278
278
case 'S' :
279
279
return layout [0 :specPos ], stdZeroSecond , layout [i + 1 :]
280
280
case 't' :
281
- // TODO: tab character '\t'
281
+ return layout [ 0 : specPos ] + " \t " , stdYield , layout [ i + 1 :]
282
282
case 'T' : // %H:%M:%S
283
- return layout [0 :specPos ], stdHour , ":%M:%S" + layout [i + 1 :]
284
- case 'u' : // TODO ISO8601 weekday
285
- //return layout[0:specPos], stdNumWeekDay, layout[i+1:]
283
+ return layout [0 :specPos ], stdYield , "%H :%M:%S" + layout [i + 1 :]
284
+ // case 'u': // TODO ISO8601 weekday
285
+ //return layout[0:specPos], stdNumWeekDay, layout[i+1:]
286
286
case 'U' :
287
287
// TODO week of the year as a decimal number (Sunday is the first day of the week)
288
288
case 'V' :
@@ -291,8 +291,8 @@ func nextStdChunk(layout string) (prefix string, std int, suffix string) {
291
291
return layout [0 :specPos ], stdNumWeekDay , layout [i + 1 :]
292
292
case 'W' :
293
293
// TODO: week of the year as a decimal number (Monday is the first day of the wee)
294
- //case 'x': // localized , not supported
295
- //case 'X': // localized , not supported
294
+ //case 'x': // locale depended , not supported
295
+ //case 'X': // locale depended , not supported
296
296
case 'y' :
297
297
return layout [0 :specPos ], stdYear , layout [i + 1 :]
298
298
case 'Y' :
0 commit comments