You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: format.go
+15-12Lines changed: 15 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,17 @@ import (
9
9
// These are predefined layouts used for the parsing and formatting of dates, times and date-times.
10
10
// Additional layouts can be composed using the specifiers detailed below:
11
11
//
12
-
// - %Y: The ISO 8601 year as a decimal number, padded to 4 digits with leading 0s.
12
+
// - %Y: The ISO 8601 year as a decimal number, padded to 4 digits with leading 0s.
13
13
// - %EY: The year in the era as a decimal number, padded to 4 digits with leading 0s.
14
-
// - %y: The ISO 8601 year without a century as a decimal number, padded to 2 digits with a leading 0, in the range 00 to 99. See note (1).
14
+
// - %y: The ISO 8601 year without a century as a decimal number, padded to 2 digits with a leading 0, in the range 00 to 99. See note (1).
15
15
// - %Ey: The year in the era without a century as a decimal number, padded to 2 digits with a leading 0, in the range 00 to 99. See notes (1) and (9).
16
-
// - %C: The century as a decimal number, padded to 2 digits with a leading 0, e.g. 19 for 1980. See note (9).
16
+
// - %C: The century as a decimal number, padded to 2 digits with a leading 0, e.g. 19 for 1980. See note (9).
17
17
// - %EC: The name of the era, either "CE" (for Common Era) "BCE" (for Before the Common Era).
18
-
// - %j: The day of the year as a decimal number, padded to 3 digits with leading 0s, in the range 001 to 366. See note (2).
19
-
// - %m: The month as a decimal number, padded to 2 digits with a leading 0, in the range 01 to 12.
20
-
// - %B: The full month name, e.g. January, February, etc.
21
-
// - %b: The abbreviated month name, e.g. Jan, Feb, etc.
22
-
// - %d: The day of the month as a decimal number, padded to 2 digits with a leading 0, in the range 01 to 31.
18
+
// - %j: The day of the year as a decimal number, padded to 3 digits with leading 0s, in the range 001 to 366. See note (2).
19
+
// - %m: The month as a decimal number, padded to 2 digits with a leading 0, in the range 01 to 12.
20
+
// - %B: The full month name, e.g. January, February, etc.
21
+
// - %b: The abbreviated month name, e.g. Jan, Feb, etc.
22
+
// - %d: The day of the month as a decimal number, padded to 2 digits with a leading 0, in the range 01 to 31.
23
23
//
24
24
// Days of week:
25
25
//
@@ -46,14 +46,14 @@ import (
46
46
//
47
47
// Millisecond precisions:
48
48
//
49
-
// - %f: Equivalent to %6f.
49
+
// - %f: Equivalent to %6f.
50
50
// - %3f: The millisecond offset within the represented second, rounded either up or down and padded to 3 digits with leading 0s.
51
51
// - %6f: The microsecond offset within the represented second, rounded either up or down and padded to 6 digits with leading 0s.
52
52
// - %9f: The nanosecond offset within the represented second, padded to 9 digits with leading 0s.
53
53
//
54
54
// Time offsets:
55
55
//
56
-
// - %z: The UTC offset in the format ±HHMM, preceded always by the sign ('+' or '-'), and padded to 4 digits with leading zeros. See notes (6), (7), and (8).
56
+
// - %z: The UTC offset in the format ±HHMM, preceded always by the sign ('+' or '-'), and padded to 4 digits with leading zeros. See notes (6), (7), and (8).
57
57
// - %Ez: Equivalent to %z, except that an offset of +0000 is formatted at 'Z', and other offsets as ±HH:MM. See notes (6) and (7).
58
58
//
59
59
// When formatting using specifiers that represent padded decimals, leading 0s can be omitted using the '-' character after the '%'.
@@ -99,6 +99,8 @@ import (
99
99
// 8. When %z is used for parsing a UTC offset, 'Z' can be used to represent an offset of +0000.
100
100
// 9. When parsing partial years (%Ey and %C) in combination with a full year (%Y or %EY),
101
101
// an error will be returned if the represented years to not match.
102
+
// 10. When parsing era names (%EC), 'AD' and 'BC' are accepted in place of 'CE' and 'BCE',
103
+
// although only the latter are used to format.
102
104
const (
103
105
// ISO 8601.
104
106
ISO8601=ISO8601DateTimeExtended
@@ -529,8 +531,9 @@ func parseDateAndTime(layout, value string, date, time, offset *int64) error {
0 commit comments