aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Donizetti <alb.donizetti@gmail.com>2017-08-01 17:41:51 +0200
committerBrad Fitzpatrick <bradfitz@golang.org>2017-08-02 16:22:49 +0000
commit193eda7291c570e84307b3122a4f496a77b0fa4c (patch)
tree243795f5464d0bce82245dd8aabf1c26e245d70f
parent6f08c935a9474a300d34e7a476628c2667142474 (diff)
downloadgo-193eda7291c570e84307b3122a4f496a77b0fa4c.tar.gz
go-193eda7291c570e84307b3122a4f496a77b0fa4c.zip
time: skip ZoneAbbr test in timezones with no abbreviation
The testZoneAbbr assumes that Parse(RFC1123, t1.Format(RFC1123)) will always succeed. This is not true because Format will fall back to the numeric zone (ex. -07) for timezones with no abbreviation, but Parse won't accept the numeric zone when the layout specifies 'MST' (an abbreviation). Skip the zone abbreviation test in timezones with no abbreviation. Fixes #21183 Change-Id: If04691cc23ae1075d8a953733024e17f5a7646de Reviewed-on: https://go-review.googlesource.com/52430 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/time/zoneinfo_windows_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/time/zoneinfo_windows_test.go b/src/time/zoneinfo_windows_test.go
index 7ac1e86822..cf3b428c09 100644
--- a/src/time/zoneinfo_windows_test.go
+++ b/src/time/zoneinfo_windows_test.go
@@ -14,6 +14,14 @@ func testZoneAbbr(t *testing.T) {
t1 := Now()
// discard nsec
t1 = Date(t1.Year(), t1.Month(), t1.Day(), t1.Hour(), t1.Minute(), t1.Second(), 0, t1.Location())
+
+ // Skip the test if we're in a timezone with no abbreviation.
+ // Format will fallback to the numeric abbreviation, and
+ // Parse(RFC1123, ..) will fail (see Issue 21183).
+ if tz := t1.Format("MST"); tz[0] == '-' || tz[0] == '+' {
+ t.Skip("No zone abbreviation")
+ }
+
t2, err := Parse(RFC1123, t1.Format(RFC1123))
if err != nil {
t.Fatalf("Parse failed: %v", err)