diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 64f9554..15c6410 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -86,6 +86,10 @@ func TestGolden(t *testing.T) { // --check validates without running: {name: "check valid does not run", args: []string{"--check", "-c", `print("RAN")`}, notOut: "RAN", wantExit: 0}, {name: "check invalid is non-zero", args: []string{"--check", "-c", `x =`}, wantExit: anyNonZero}, + // named time zones resolve via the embedded IANA tzdata (no host + // /usr/share/zoneinfo needed — see main.go's time/tzdata import): + {name: "named timezone is valid", args: []string{"-c", `load("time","is_valid_timezone"); print(is_valid_timezone("America/New_York"))`}, wantOut: "True\n", wantExit: 0}, + {name: "named timezone converts", args: []string{"-c", `load("time","parse_time"); print(parse_time("2021-03-22T12:00:00Z").in_location("America/New_York").hour)`}, wantOut: "8\n", wantExit: 0}, } for _, c := range cases { diff --git a/main.go b/main.go index fad87c9..d4eed8f 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,12 @@ package main import ( "os" + // Embed the IANA time-zone database into the binary so named zones + // (time.parse_time location=, in_location, is_valid_timezone) resolve even + // when the host has no /usr/share/zoneinfo — i.e. minimal/scratch/distroless + // containers and slimmed binaries. Costs ~450 KB; keeps the CLI portable + // ("runs anywhere") instead of depending on host tz data. + _ "time/tzdata" "bitbucket.org/neiku/hlog" "bitbucket.org/neiku/winornot"