Skip to content

Commit 0298bc8

Browse files
committed
sandbox: fix missing timezone data
The gvisor sandbox containers were missing tzinfo, as the busybox image does not include it. Updates golang/go#38727 Change-Id: Idc2c705e3ee31de1411507bb3abdf1afb28eeda9 Reviewed-on: https://go-review.googlesource.com/c/playground/+/231057 Run-TryBot: Alexander Rakoczy <alex@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 195e12f commit 0298bc8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

sandbox/Dockerfile.gvisor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ FROM golang/playground-sandbox AS server
1414
FROM busybox:glibc
1515

1616
COPY --from=server /usr/local/bin/play-sandbox /usr/local/bin/play-sandbox
17+
COPY --from=server /usr/share/zoneinfo /usr/share/zoneinfo
1718

1819
ENTRYPOINT ["/usr/local/bin/play-sandbox"]

tests.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,4 +570,29 @@ func main() {
570570
<-c
571571
}
572572
`, want: "timeout running program"},
573+
{
574+
name: "timezone_info_exists",
575+
prog: `
576+
package main
577+
578+
import (
579+
"fmt"
580+
"time"
581+
)
582+
583+
func main() {
584+
loc, _ := time.LoadLocation("Europe/Berlin")
585+
586+
// This will look for the name CEST in the Europe/Berlin time zone.
587+
const longForm = "Jan 2, 2006 at 3:04pm (MST)"
588+
t, _ := time.ParseInLocation(longForm, "Jul 9, 2012 at 5:02am (CEST)", loc)
589+
fmt.Println(t)
590+
591+
// Note: without explicit zone, returns time in given location.
592+
const shortForm = "2006-Jan-02"
593+
t, _ = time.ParseInLocation(shortForm, "2012-Jul-09", loc)
594+
fmt.Println(t)
595+
596+
}
597+
`, want: "2012-07-09 05:02:00 +0200 CEST\n2012-07-09 00:00:00 +0200 CEST\n"},
573598
}

0 commit comments

Comments
 (0)