Skip to content

Commit

Permalink
skip timezone conversion on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Jun 30, 2022
1 parent fcc2e42 commit efe3ccb
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"syscall"
"time"

Expand All @@ -42,13 +43,23 @@ func main() {

log.Println("version =", version)

// Exercise timezone conversions, which demonstrates tzdata is provided
// by the base image.
now := time.Now()
loc, _ := time.LoadLocation("UTC")
fmt.Printf("UTC Time: %s\n", now.In(loc))
loc, _ = time.LoadLocation("America/New_York")
fmt.Printf("New York Time: %s\n", now.In(loc))
if runtime.GOOS == "windows" {
// Go seems to not load location data from Windows, so timezone
// conversion fails unless tzdata is embedded in the Go program
// with the go build tag `timetzdata`. Since we want to test
// loading tzdata provided by the base image below, we'll just
// skip that for Windows here.
// See https://github.com/google/ko/issues/739
log.Println("skipping timezone conversion on Windows")
} else {
// Exercise timezone conversions, which demonstrates tzdata is provided
// by the base image.
now := time.Now()
loc, _ := time.LoadLocation("UTC")
fmt.Printf("UTC Time: %s\n", now.In(loc))
loc, _ = time.LoadLocation("America/New_York")
fmt.Printf("New York Time: %s\n", now.In(loc))
}

dp := os.Getenv("KO_DATA_PATH")
file := filepath.Join(dp, *f)
Expand Down

0 comments on commit efe3ccb

Please sign in to comment.