Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading