Skip to content

Commit 8874c8c

Browse files
committed
time: test seconds offset adjustment
1 parent aa05238 commit 8874c8c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/time/format_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,3 +893,35 @@ func TestParseFractionalSecondsLongerThanNineDigits(t *testing.T) {
893893
}
894894
}
895895
}
896+
897+
// Issue 53919
898+
func TestParseInLocationSecondsAdjusted(t *testing.T) {
899+
t.Parallel()
900+
901+
zName := "Asia/Shanghai"
902+
903+
z, err := LoadLocation(zName)
904+
if err != nil {
905+
t.Errorf("Unexpected error: %v", err)
906+
return
907+
}
908+
909+
ts := Date(1900, 1, 1, 0, 0, 0, 0, z)
910+
s := ts.Format(RFC3339Nano)
911+
912+
ts, err = ParseInLocation(RFC3339, s, z)
913+
if err != nil {
914+
t.Errorf("Unexpected error: %v", err)
915+
return
916+
}
917+
918+
if got := ts.Location().String(); zName != got {
919+
t.Errorf("ParseInLocation returns wrong location; got %q, want %q", got, zName)
920+
921+
ts = ts.In(z)
922+
}
923+
924+
if got := ts.Format(RFC3339Nano); s != got {
925+
t.Errorf("seconds were not adjusted; got %q, want %q", got, s)
926+
}
927+
}

0 commit comments

Comments
 (0)