sec2localtime is returning UTC time unless TZ was explicitly set either via environment variable TZ or --tz cli fag. Golang sets time.Local correctly even without TZ. But it is overridden at SetTZFromEnv. When TZ is unset (i.e. ""), LoadLocation returns UTCdoc.
If the name is "" or "UTC", LoadLocation returns UTC. If the name is "Local", LoadLocation returns Local.
❯ date
Tue 17 Sep 2024 10:41:02 AM EDT
❯ printf '{"ts": %s }' $(date +"%s") | go run cmd/mlr/main.go --jsonl put '$ts = sec2localtime($ts)'
{"ts": "2024-09-17 10:41:06"}
❯ printf '{"ts": %s }' $(date +"%s") | mlr --jsonl put '$ts = sec2localtime($ts)'
{"ts": "2024-09-17 14:41:09"}
❯ mlr --version
mlr 6.12.0
❯ env | grep TZ
❯ env | grep TZ || echo "not found"
not found
sec2localtime is returning UTC time unless TZ was explicitly set either via environment variable
TZ
or--tz
cli fag. Golang setstime.Local
correctly even withoutTZ
. But it is overridden atSetTZFromEnv
. When TZ is unset (i.e. ""), LoadLocation returnsUTC
doc.