diff options
| author | Joel Stemmer <stemmertech@gmail.com> | 2014-08-08 12:42:20 -0700 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2014-08-08 12:42:20 -0700 |
| commit | 298c623e8caadf68198ba7bc4e6b128cb87983d7 (patch) | |
| tree | d8d28272468847ca42dab184ed5fbffab7ffea56 /src/pkg | |
| parent | f69f45c5383044c503add49d12659e14c1496491 (diff) | |
| download | go-298c623e8caadf68198ba7bc4e6b128cb87983d7.tar.xz | |
time: Fix missing colon when formatting time zone offsets with seconds
When formatting time zone offsets with seconds using the stdISO8601Colon
and stdNumColon layouts, the colon was missing between the hour and minute
parts.
Fixes #8497.
LGTM=r
R=golang-codereviews, iant, gobot, r
CC=golang-codereviews
https://golang.org/cl/126840043
Diffstat (limited to 'src/pkg')
| -rw-r--r-- | src/pkg/time/format.go | 2 | ||||
| -rw-r--r-- | src/pkg/time/format_test.go | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/pkg/time/format.go b/src/pkg/time/format.go index 14b1250cb0..04e79f32dc 100644 --- a/src/pkg/time/format.go +++ b/src/pkg/time/format.go @@ -556,7 +556,7 @@ func (t Time) Format(layout string) string { b = append(b, '+') } b = appendUint(b, uint(zone/60), '0') - if std == stdISO8601ColonTZ || std == stdNumColonTZ { + if std == stdISO8601ColonTZ || std == stdNumColonTZ || std == stdISO8601ColonSecondsTZ || std == stdNumColonSecondsTZ { b = append(b, ':') } b = appendUint(b, uint(zone%60), '0') diff --git a/src/pkg/time/format_test.go b/src/pkg/time/format_test.go index 3bc8f42946..a7c6d55b2f 100644 --- a/src/pkg/time/format_test.go +++ b/src/pkg/time/format_test.go @@ -502,10 +502,11 @@ func TestParseSecondsInTimeZone(t *testing.T) { } func TestFormatSecondsInTimeZone(t *testing.T) { - d := Date(1871, 9, 17, 20, 4, 26, 0, FixedZone("LMT", -(34*60+8))) - timestr := d.Format("2006-01-02T15:04:05Z070000") - expected := "1871-09-17T20:04:26-003408" - if timestr != expected { - t.Errorf("Got %s, want %s", timestr, expected) + for _, test := range secondsTimeZoneOffsetTests { + d := Date(1871, 1, 1, 5, 33, 2, 0, FixedZone("LMT", test.expectedoffset)) + timestr := d.Format(test.format) + if timestr != test.value { + t.Errorf("Format = %s, want %s", timestr, test.value) + } } } |
