Skip to content

Commit 5e9ad4a

Browse files
agnivadebradfitz
authored andcommitted
time: handle negative offsets on js/wasm
Fixes #28649 Change-Id: I9f6807ee3c3007f670dd509780805c7b255a2bda Reviewed-on: https://go-review.googlesource.com/c/148338 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 13baf4b commit 5e9ad4a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/time/zoneinfo_js.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func initLocal() {
3333
z.name = "UTC"
3434
if offset < 0 {
3535
z.name += "-"
36+
offset *= -1
3637
} else {
3738
z.name += "+"
3839
}
@@ -44,8 +45,8 @@ func initLocal() {
4445
localLoc.zone = []zone{z}
4546
}
4647

47-
// itoa is just the fast path implementation copied from strconv.Itoa.
48-
// No timezone hour can exceed 100, so the fast path will always satisfy.
48+
// itoa is like strconv.Itoa but only works for values of i in range [0,99].
49+
// It panics if i is out of range.
4950
func itoa(i int) string {
5051
if i < 10 {
5152
return digits[i : i+1]

0 commit comments

Comments
 (0)