aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2014-09-29 13:46:12 +1000
committerBrad Fitzpatrick <bradfitz@golang.org>2014-09-29 13:46:12 +1000
commit370a9c9c0ec8abe2cdffcd7876086b3329f8b668 (patch)
tree1beb4673ee2c01f625fd55806aa141178679b1e0
parentf3c81ed821268e2f2e2945b0816f495809bbdf21 (diff)
downloadgo-370a9c9c0ec8abe2cdffcd7876086b3329f8b668.tar.gz
go-370a9c9c0ec8abe2cdffcd7876086b3329f8b668.zip
[release-branch.go1.3] time: removed from tests now obsolete assumption about Australian tz abbreviations
««« CL 130920043 / 7dba9475ee72 time: removed from tests now obsolete assumption about Australian tz abbreviations Australian timezones abbreviation for standard and daylight saving time were recently changed from EST for both to AEST and AEDT in the icann tz database (see changelog on www.iana.org/time-zones). A test in the time package was written to check that the ParseInLocation function understand that Feb EST and Aug EST are different time zones, even though they are both called EST. This is no longer the case, and the Date function now returns AEST or AEDT for australian tz on every Linux system with an up to date tz database (and this makes the test fail). Since I wasn't able to find another country that 1) uses daylight saving and 2) has the same abbreviation for both on tzdata, I changed the test to make sure that ParseInLocation does not get confused when it parses, in different locations, two dates with the same abbreviation (this was suggested in the mailing list). Fixes #8547. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/130920043 »»» LGTM=dsymonds R=rsc, dsymonds CC=golang-codereviews https://golang.org/cl/153720043
-rw-r--r--src/pkg/time/format_test.go36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/pkg/time/format_test.go b/src/pkg/time/format_test.go
index 3bc8f42946..46a5981554 100644
--- a/src/pkg/time/format_test.go
+++ b/src/pkg/time/format_test.go
@@ -183,39 +183,45 @@ func TestParse(t *testing.T) {
}
}
-func TestParseInSydney(t *testing.T) {
- loc, err := LoadLocation("Australia/Sydney")
+func TestParseInLocation(t *testing.T) {
+ // Check that Parse (and ParseInLocation) understand that
+ // Feb 01 AST (Arabia Standard Time) and Feb 01 AST (Atlantic Standard Time)
+ // are in different time zones even though both are called AST
+
+ baghdad, err := LoadLocation("Asia/Baghdad")
if err != nil {
t.Fatal(err)
}
- // Check that Parse (and ParseInLocation) understand
- // that Feb EST and Aug EST are different time zones in Sydney
- // even though both are called EST.
- t1, err := ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 EST", loc)
+ t1, err := ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", baghdad)
if err != nil {
t.Fatal(err)
}
- t2 := Date(2013, February, 1, 00, 00, 00, 0, loc)
+ t2 := Date(2013, February, 1, 00, 00, 00, 0, baghdad)
if t1 != t2 {
- t.Fatalf("ParseInLocation(Feb 01 2013 EST, Sydney) = %v, want %v", t1, t2)
+ t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad) = %v, want %v", t1, t2)
}
_, offset := t1.Zone()
- if offset != 11*60*60 {
- t.Fatalf("ParseInLocation(Feb 01 2013 EST, Sydney).Zone = _, %d, want _, %d", offset, 11*60*60)
+ if offset != 3*60*60 {
+ t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad).Zone = _, %d, want _, %d", offset, 3*60*60)
+ }
+
+ blancSablon, err := LoadLocation("America/Blanc-Sablon")
+ if err != nil {
+ t.Fatal(err)
}
- t1, err = ParseInLocation("Jan 02 2006 MST", "Aug 01 2013 EST", loc)
+ t1, err = ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", blancSablon)
if err != nil {
t.Fatal(err)
}
- t2 = Date(2013, August, 1, 00, 00, 00, 0, loc)
+ t2 = Date(2013, February, 1, 00, 00, 00, 0, blancSablon)
if t1 != t2 {
- t.Fatalf("ParseInLocation(Aug 01 2013 EST, Sydney) = %v, want %v", t1, t2)
+ t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon) = %v, want %v", t1, t2)
}
_, offset = t1.Zone()
- if offset != 10*60*60 {
- t.Fatalf("ParseInLocation(Aug 01 2013 EST, Sydney).Zone = _, %d, want _, %d", offset, 10*60*60)
+ if offset != -4*60*60 {
+ t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon).Zone = _, %d, want _, %d", offset, -4*60*60)
}
}