From 08fdd554f58dbf9851905a4fa89ca54bd3bcaa8d Mon Sep 17 00:00:00 2001 From: John Kerl Date: Wed, 20 Oct 2021 21:48:26 -0400 Subject: [PATCH] Date-time-related issues: 331, 332, 359 (#704) * xvright * Left/right trim on --repifs * Fix emit-flatten when main & emit output file formats differ * Port localtime DSL functions from C to Go * Port localtime DSL functions from C to Go (#703) * xvright * Left/right trim on --repifs * Fix emit-flatten when main & emit output file formats differ * Port localtime DSL functions from C to Go * Time-related issues: 331, 332, 359, 477 --- build-go-src-test-man-doc.sh | 2 + docs6/src/manpage.md | 138 +++++++++---- docs6/src/manpage.txt | 138 +++++++++---- docs6/src/online-help.md | 3 +- docs6/src/reference-dsl-builtin-functions.md | 113 +++++++--- docs6/src/reference-main-flag-list.md | 2 + go/build | 2 + go/mktags | 2 +- .../dsl-local-date-time-functions/0001/expout | 11 - .../dsl-local-date-time-functions/0002/expout | 16 -- .../dsl-local-date-time-functions/0001/cmd | 0 .../dsl-local-date-time-functions/0001/env | 0 .../dsl-local-date-time-functions/0001/experr | 0 .../dsl-local-date-time-functions/0001/expout | 11 + .../dsl-local-date-time-functions/0001/input | 0 .../dsl-local-date-time-functions/0001/mlr | 0 .../dsl-local-date-time-functions/0002/cmd | 0 .../dsl-local-date-time-functions/0002/env | 0 .../dsl-local-date-time-functions/0002/experr | 0 .../dsl-local-date-time-functions/0002/expout | 16 ++ .../dsl-local-date-time-functions/0002/input | 0 .../dsl-local-date-time-functions/0002/mlr | 0 .../dsl-local-date-time-functions/0003/cmd | 0 .../dsl-local-date-time-functions/0003/env | 0 .../dsl-local-date-time-functions/0003/experr | 0 .../dsl-local-date-time-functions/0003/expout | 0 .../dsl-local-date-time-functions/0003/input | 0 .../dsl-local-date-time-functions/0003/mlr | 0 .../dsl-local-date-time-functions/0004/cmd | 0 .../dsl-local-date-time-functions/0004/env | 0 .../dsl-local-date-time-functions/0004/experr | 0 .../dsl-local-date-time-functions/0004/expout | 0 .../dsl-local-date-time-functions/0004/input | 0 .../dsl-local-date-time-functions/0004/mlr | 0 .../gmt2localtime-istanbul/cmd | 1 + .../gmt2localtime-istanbul/experr | 0 .../gmt2localtime-istanbul/expout | 5 + .../gmt2localtime-sao_paulo/cmd | 1 + .../gmt2localtime-sao_paulo/experr | 0 .../gmt2localtime-sao_paulo/expout | 5 + .../gmt2localtime-utc/cmd | 1 + .../gmt2localtime-utc/experr | 0 .../gmt2localtime-utc/expout | 5 + .../gmt2sec-istanbul/cmd | 1 + .../gmt2sec-istanbul/experr | 0 .../gmt2sec-istanbul/expout | 5 + .../gmt2sec-sao_paulo/cmd | 1 + .../gmt2sec-sao_paulo/experr | 0 .../gmt2sec-sao_paulo/expout | 5 + .../gmt2sec-utc/cmd | 1 + .../gmt2sec-utc/experr | 0 .../gmt2sec-utc/expout | 5 + .../localtime2sec-istanbul/cmd | 1 + .../localtime2sec-istanbul/experr | 0 .../localtime2sec-istanbul/expout | 5 + .../localtime2sec-sao_paulo/cmd | 1 + .../localtime2sec-sao_paulo/experr | 0 .../localtime2sec-sao_paulo/expout | 5 + .../localtime2sec-utc/cmd | 1 + .../localtime2sec-utc/experr | 0 .../localtime2sec-utc/expout | 5 + .../not-a-valid-timezone/cmd | 1 + .../not-a-valid-timezone/experr | 1 + .../not-a-valid-timezone/expout | 0 .../not-a-valid-timezone/should-fail | 0 .../sec2gmt-istanbul/cmd | 1 + .../sec2gmt-istanbul/experr | 0 .../sec2gmt-istanbul/expout | 8 + .../sec2gmt-sao_paulo/cmd | 1 + .../sec2gmt-sao_paulo/experr | 0 .../sec2gmt-sao_paulo/expout | 8 + .../sec2gmt-utc/cmd | 1 + .../sec2gmt-utc/experr | 0 .../sec2gmt-utc/expout | 8 + .../sec2gmtdate-istanbul/cmd | 1 + .../sec2gmtdate-istanbul/experr | 0 .../sec2gmtdate-istanbul/expout | 6 + .../sec2gmtdate-sao_paulo/cmd | 1 + .../sec2gmtdate-sao_paulo/experr | 0 .../sec2gmtdate-sao_paulo/expout | 6 + .../sec2gmtdate-utc/cmd | 1 + .../sec2gmtdate-utc/experr | 0 .../sec2gmtdate-utc/expout | 6 + .../sec2localdate-istanbul/cmd | 1 + .../sec2localdate-istanbul/experr | 0 .../sec2localdate-istanbul/expout | 6 + .../sec2localdate-sao_paulo/cmd | 1 + .../sec2localdate-sao_paulo/experr | 0 .../sec2localdate-sao_paulo/expout | 6 + .../sec2localdate-utc/cmd | 1 + .../sec2localdate-utc/experr | 0 .../sec2localdate-utc/expout | 6 + .../sec2localtime-istanbul/cmd | 1 + .../sec2localtime-istanbul/experr | 0 .../sec2localtime-istanbul/expout | 8 + .../sec2localtime-sao_paulo/cmd | 1 + .../sec2localtime-sao_paulo/experr | 0 .../sec2localtime-sao_paulo/expout | 8 + .../sec2localtime-utc/cmd | 1 + .../sec2localtime-utc/experr | 0 .../sec2localtime-utc/expout | 8 + .../strftime-istanbul/cmd | 1 + .../strftime-istanbul/experr | 0 .../strftime-istanbul/expout | 12 ++ .../strftime-sao_paulo/cmd | 1 + .../strftime-sao_paulo/experr | 0 .../strftime-sao_paulo/expout | 12 ++ .../strftime-utc/cmd | 1 + .../strftime-utc/experr | 0 .../strftime-utc/expout | 12 ++ .../strftime_local-istanbul/cmd | 1 + .../strftime_local-istanbul/experr | 0 .../strftime_local-istanbul/expout | 11 + .../strftime_local-sao_paulo/cmd | 1 + .../strftime_local-sao_paulo/experr | 0 .../strftime_local-sao_paulo/expout | 11 + .../strftime_local-utc/cmd | 1 + .../strftime_local-utc/experr | 0 .../strftime_local-utc/expout | 11 + .../strptime-istanbul/cmd | 1 + .../strptime-istanbul/experr | 0 .../strptime-istanbul/expout | 9 + .../strptime-sao_paulo/cmd | 1 + .../strptime-sao_paulo/experr | 0 .../strptime-sao_paulo/expout | 9 + .../strptime-utc/cmd | 1 + .../strptime-utc/experr | 0 .../strptime-utc/expout | 9 + .../strptime-z/cmd | 1 + .../strptime-z/experr | 0 .../strptime-z/expout | 15 ++ .../strptime-z/mlr | 17 ++ .../strptime_local-istanbul/cmd | 1 + .../strptime_local-istanbul/experr | 0 .../strptime_local-istanbul/expout | 4 + .../strptime_local-sao_paulo/cmd | 1 + .../strptime_local-sao_paulo/experr | 0 .../strptime_local-sao_paulo/expout | 4 + .../strptime_local-utc/cmd | 1 + .../strptime_local-utc/experr | 0 .../strptime_local-utc/expout | 4 + go/regtest/cases/verb-label/0009/experr | 1 - go/regtest/input/gmt2localtime-tz.mlr | 10 + go/regtest/input/gmt2sec-tz.mlr | 10 + go/regtest/input/localtime2sec-tz.mlr | 10 + go/regtest/input/sec2gmt-tz.mlr | 13 ++ go/regtest/input/sec2gmtdate-tz.mlr | 11 + go/regtest/input/sec2localdate-tz.mlr | 11 + go/regtest/input/sec2localtime-tz.mlr | 13 ++ go/regtest/input/strftime-tz.mlr | 17 ++ go/regtest/input/strftime_local-tz.mlr | 17 ++ go/regtest/input/strptime-tz.mlr | 14 ++ go/regtest/input/strptime_local-tz.mlr | 9 + go/src/cli/option_parse.go | 11 + go/src/climain/mlrcli_parse.go | 3 + go/src/dsl/cst/builtin_function_manager.go | 194 ++++++++++++------ go/src/dsl/cst/lvalues.go | 7 +- go/src/lib/time.go | 50 ++++- go/src/transformers/label.go | 3 +- go/src/types/mlrval_functions_time.go | 17 +- go/todo.txt | 74 ++++++- man6/manpage.txt | 138 +++++++++---- man6/mlr6.1 | 152 ++++++++++---- 163 files changed, 1257 insertions(+), 287 deletions(-) delete mode 100644 go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/expout delete mode 100644 go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/expout rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0001/cmd (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0001/env (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0001/experr (100%) create mode 100644 go/regtest/cases/dsl-local-date-time-functions/0001/expout rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0001/input (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0001/mlr (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0002/cmd (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0002/env (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0002/experr (100%) create mode 100644 go/regtest/cases/dsl-local-date-time-functions/0002/expout rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0002/input (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0002/mlr (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0003/cmd (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0003/env (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0003/experr (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0003/expout (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0003/input (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0003/mlr (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0004/cmd (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0004/env (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0004/experr (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0004/expout (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0004/input (100%) rename go/regtest/{cases-pending-windows => cases}/dsl-local-date-time-functions/0004/mlr (100%) create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/should-fail create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-utc/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-z/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-z/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-z/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime-z/mlr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/expout create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/cmd create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/experr create mode 100644 go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/expout create mode 100644 go/regtest/input/gmt2localtime-tz.mlr create mode 100644 go/regtest/input/gmt2sec-tz.mlr create mode 100644 go/regtest/input/localtime2sec-tz.mlr create mode 100644 go/regtest/input/sec2gmt-tz.mlr create mode 100644 go/regtest/input/sec2gmtdate-tz.mlr create mode 100644 go/regtest/input/sec2localdate-tz.mlr create mode 100644 go/regtest/input/sec2localtime-tz.mlr create mode 100644 go/regtest/input/strftime-tz.mlr create mode 100644 go/regtest/input/strftime_local-tz.mlr create mode 100644 go/regtest/input/strptime-tz.mlr create mode 100644 go/regtest/input/strptime_local-tz.mlr diff --git a/build-go-src-test-man-doc.sh b/build-go-src-test-man-doc.sh index e9afe2d8f..2b47142b6 100644 --- a/build-go-src-test-man-doc.sh +++ b/build-go-src-test-man-doc.sh @@ -12,6 +12,8 @@ # turn *.md.in into *.md (live code samples), using mlr from the $PATH # turn *.md into docs6/site HTML and CSS files +export TZ="" + set -euo pipefail cd go diff --git a/docs6/src/manpage.md b/docs6/src/manpage.md index c8177535d..787e93c2f 100644 --- a/docs6/src/manpage.md +++ b/docs6/src/manpage.md @@ -192,20 +192,21 @@ FUNCTION LIST asserting_present asserting_string atan atan2 atanh bitcount boolean capitalize cbrt ceil clean_whitespace collapse_whitespace cos cosh depth dhms2fsec dhms2sec erf erfc every exp expm1 flatten float floor fmtnum fold - fsec2dhms fsec2hms get_keys get_values gmt2sec gsub haskey hexfmt hms2fsec - hms2sec hostname int invqnorm is_absent is_array is_bool is_boolean is_empty - is_empty_map is_error is_float is_int is_map is_nonempty_map is_not_array - is_not_empty is_not_map is_not_null is_null is_numeric is_present is_string - joink joinkv joinv json_parse json_stringify leafcount length localtime2sec - log log10 log1p logifit lstrip madd mapdiff mapexcept mapselect mapsum max md5 - mexp min mmul msub os pow qnorm reduce regextract regextract_or_else round - roundm rstrip sec2dhms sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime - select sgn sha1 sha256 sha512 sin sinh sort splita splitax splitkv splitkvx - splitnv splitnvx sqrt ssub strftime strftime_local string strip strlen - strptime strptime_local sub substr substr0 substr1 system systime systimeint - tan tanh tolower toupper truncate typeof unflatten uptime urand urand32 - urandint urandrange version ! != !=~ % & && * ** + - . .* .+ .- ./ / // < << - <= <=> == =~ > >= >> >>> ?: ?? ??? ^ ^^ | || ~ + fsec2dhms fsec2hms get_keys get_values gmt2localtime gmt2sec gsub haskey + hexfmt hms2fsec hms2sec hostname int invqnorm is_absent is_array is_bool + is_boolean is_empty is_empty_map is_error is_float is_int is_map + is_nonempty_map is_not_array is_not_empty is_not_map is_not_null is_null + is_numeric is_present is_string joink joinkv joinv json_parse json_stringify + leafcount length localtime2gmt localtime2sec log log10 log1p logifit lstrip + madd mapdiff mapexcept mapselect mapsum max md5 mexp min mmul msub os pow + qnorm reduce regextract regextract_or_else round roundm rstrip sec2dhms + sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime select sgn sha1 sha256 + sha512 sin sinh sort splita splitax splitkv splitkvx splitnv splitnvx sqrt + ssub strftime strftime_local string strip strlen strptime strptime_local sub + substr substr0 substr1 system systime systimeint tan tanh tolower toupper + truncate typeof unflatten uptime urand urand32 urandint urandrange version ! + != !=~ % & && * ** + - . .* .+ .- ./ / // < << <= <=> == =~ > >= >> >>> ?: ?? + ??? ^ ^^ | || ~ COMMENTS-IN-DATA FLAGS Miller lets you put comments in your data, such as @@ -470,6 +471,8 @@ MISCELLANEOUS FLAGS the `fmtnum` function and the `format-values` verb. --seed {n} with `n` of the form `12345678` or `0xcafefeed`. For `put`/`filter` `urand`, `urandint`, and `urand32`. + --tz {timezone} Specify timezone, overriding `$TZ` environment + variable (if any). -I Process files in-place. For each file name on the command line, output is written to a temp file in the same directory, which is then renamed over the @@ -1886,6 +1889,7 @@ FUNCTIONS FOR FILTER/PUT any (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for any array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: any([10,20,30], func(e) {return $index == e}) Map example: any({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) @@ -1894,6 +1898,7 @@ FUNCTIONS FOR FILTER/PUT apply (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, applies the function to each element of the array/map. For arrays, the function should take one argument, for array element; it should return a new element. For maps, it should take two arguments, for map-element key and value; it should return a new key-value pair (i.e. a single-entry map). + Examples: Array example: apply([1,2,3,4,5], func(e) {return e ** 3}) returns [1, 8, 27, 64, 125]. Map example: apply({"a":1, "b":3, "c":5}, func(k,v) {return {toupper(k): v ** 2}}) returns {"A": 1, "B":9, "C": 25}", @@ -2017,6 +2022,7 @@ FUNCTIONS FOR FILTER/PUT every (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for every array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: every(["a", "b", "c"], func(e) {return $[e] >= 0}) Map example: every({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) @@ -2028,8 +2034,9 @@ FUNCTIONS FOR FILTER/PUT flatten (class=collections #args=3) Flattens multi-level maps to single-level ones. Useful for nested JSON-like structures for non-JSON file formats like CSV. - Example: flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. - Example: flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. + Examples: + flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. + flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. Two-argument version: flatten($*, ".") is the same as flatten("", ".", $*). float @@ -2043,6 +2050,7 @@ FUNCTIONS FOR FILTER/PUT fold (class=higher-order-functions #args=3) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is taken from the third argument. + Examples: Array example: fold([1,2,3,4,5], func(acc,e) {return acc + e**3}, 10000) returns 10225. Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": accv+ev**2}}, {"sum":10000}) returns 10035. @@ -2058,11 +2066,18 @@ FUNCTIONS FOR FILTER/PUT get_values (class=collections #args=1) Returns array of keys of map or array -- in the latter case, returns a copy of the array + gmt2localtime + (class=time #args=1) Convert from a GMT-time string to a local-time string, consulting $TZ + Example: + gmt2localtime("1999-12-31T22:00:00Z") = "2000-01-01 00:00:00" with TZ="Asia/Istanbul" + gmt2sec (class=time #args=1) Parses GMT timestamp as integer seconds since the epoch. + Example: + gmt2sec("2001-02-03T04:05:06Z") = 981173106 gsub - (class=string #args=3) Example: '$name=gsub($name, "old", "new")' (replace all). + (class=string #args=3) '$name=gsub($name, "old", "new")' (replace all). haskey (class=collections #args=2) True/false if map has/hasn't key, e.g. 'haskey($*, "a")' or 'haskey(mymap, mykey)', or true/false if array index is in bounds / out of bounds. Error if 1st argument is not a map or array. Note -n..-1 alias to 1..n in Miller arrays. @@ -2144,13 +2159,15 @@ FUNCTIONS FOR FILTER/PUT joink (class=conversion #args=2) Makes string from map/array keys. - Example: joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". - Example: joink([1,2,3], ",") = "1,2,3". + Examples: + joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". + joink([1,2,3], ",") = "1,2,3". joinkv (class=conversion #args=3) Makes string from map/array key-value pairs. - Example: joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" - Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" + Examples: + joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" + joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" joinv (class=conversion #args=2) Makes string from map/array values. joinv([3,4,5], ",") = "3,4,5" joinv({"a":3,"b":4,"c":5}, ",") = "3,4,5" @@ -2167,8 +2184,15 @@ FUNCTIONS FOR FILTER/PUT length (class=collections #args=1) Counts number of top-level entries in array/map. Scalars have length 1. + localtime2gmt + (class=time #args=1) Convert from a local-time string to a GMT-time string, consulting $TZ + Example: + localtime2gmt("2000-01-01 00:00:00") = "1999-12-31T22:00:00Z" with TZ="Asia/Istanbul" + localtime2sec (class=time #args=1) Parses local timestamp as integer seconds since the epoch. Consults $TZ environment variable. + Example: + localtime2sec("2001-02-03 04:05:06") = 981165906 with TZ="Asia/Istanbul" log (class=math #args=1) Natural (base-e) logarithm. @@ -2229,14 +2253,15 @@ FUNCTIONS FOR FILTER/PUT reduce (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element, and return the accumulated element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is the first element for arrays, or the first element's key-value pair for maps. + Examples: Array example: reduce([1,2,3,4,5], func(acc,e) {return acc + e**3}) returns 225. Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_of_squares": accv + ev**2}}) returns {"sum_of_squares": 35}. regextract - (class=string #args=2) Example: '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' + (class=string #args=2) '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' regextract_or_else - (class=string #args=3) Example: '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' + (class=string #args=3) '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' round (class=math #args=1) Round to nearest integer. @@ -2251,22 +2276,35 @@ FUNCTIONS FOR FILTER/PUT (class=time #args=1) Formats integer seconds as in sec2dhms(500000) = "5d18h53m20s" sec2gmt - (class=time #args=1,2) Formats seconds since epoch (integer part) as GMT timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch as GMT timestamp. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part. + Examples: + sec2gmt(1234567890) = "2009-02-13T23:31:30Z" + sec2gmt(1234567890.123456) = "2009-02-13T23:31:30Z" + sec2gmt(1234567890.123456, 6) = "2009-02-13T23:31:30.123456Z" sec2gmtdate - (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. + (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date. Leaves non-numbers as-is. + Example: + sec2gmtdate(1440768801.7) = "2015-08-28". sec2hms (class=time #args=1) Formats integer seconds as in sec2hms(5000) = "01:23:20" sec2localdate - (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. Consults $TZ environment variable. + (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date. Leaves non-numbers as-is. Consults $TZ environment variable. + Example: + sec2localdate(1440768801.7) = "2015-08-28" with TZ="Asia/Istanbul" sec2localtime - (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp. Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + Examples: + sec2localtime(1234567890) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" + sec2localtime(1234567890.123456) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" + sec2localtime(1234567890.123456, 6) = "2009-02-14 01:31:30.123456" with TZ="Asia/Istanbul" select (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, includes each input element in the output if the function returns true. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: select([1,2,3,4,5], func(e) {return e >= 3}) returns [3, 4, 5]. Map example: select({"a":1, "b":3, "c":5}, func(k,v) {return v >= 3}) returns {"b":3, "c": 5}. @@ -2290,32 +2328,39 @@ FUNCTIONS FOR FILTER/PUT sort (class=higher-order-functions #args=1-2) Given a map or array as first argument and string flags or function as optional second argument, returns a sorted copy of the input. With one argument, sorts array elements naturally, and maps naturally by map keys. If the second argument is a string, it can contain any of "f" for lexical (default "n" for natural/numeric), "), "c" for case-folded lexical, and "r" for reversed/descending sort. If the second argument is a function, then for arrays it should take two arguments a and b, returning < 0, 0, or > 0 as a < b, a == b, or a > b respectively; for maps the function should take four arguments ak, av, bk, and bv, again returning < 0, 0, or > 0, using a and b's keys and values. + Examples: Array example: sort([5,2,3,1,4], func(a,b) {return b <=> a}) returns [5,4,3,2,1]. Map example: sort({"c":2,"a":3,"b":1}, func(ak,av,bk,bv) {return bv <=> av}) returns {"a":3,"c":2,"b":1}. splita (class=conversion #args=2) Splits string into array with type inference. - Example: splita("3,4,5", ",") = [3,4,5] + Example: + splita("3,4,5", ",") = [3,4,5] splitax (class=conversion #args=2) Splits string into array without type inference. - Example: splita("3,4,5", ",") = ["3","4","5"] + Example: + splita("3,4,5", ",") = ["3","4","5"] splitkv (class=conversion #args=3) Splits string by separators into map with type inference. - Example: splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} + Example: + splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} splitkvx (class=conversion #args=3) Splits string by separators into map without type inference (keys and values are strings). - Example: splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} + Example: + splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} splitnv (class=conversion #args=2) Splits string by separator into integer-indexed map with type inference. - Example: splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} + Example: + splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} splitnvx (class=conversion #args=2) Splits string by separator into integer-indexed map without type inference (values are strings). - Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} + Example: + splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} sqrt (class=math #args=1) Square root. @@ -2324,10 +2369,16 @@ FUNCTIONS FOR FILTER/PUT (class=string #args=3) Like sub but does no regexing. No characters are special. strftime - (class=time #args=2) Formats seconds since the epoch as timestamp, e.g. strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z", and strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z". Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. + (class=time #args=2) Formats seconds since the epoch as timestamp. Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. + Examples: + strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z" + strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z" strftime_local (class=time #args=2) Like strftime but consults the $TZ environment variable to get local time zone. + Examples: + strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%S %z") = "2015-08-28 16:33:21 +0300" with TZ="Asia/Istanbul" + strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%3S %z") = "2015-08-28 16:33:21.700 +0300" with TZ="Asia/Istanbul" string (class=conversion #args=1) Convert int/float/bool/string/array/map to string. @@ -2339,13 +2390,22 @@ FUNCTIONS FOR FILTER/PUT (class=string #args=1) String length. strptime - (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch, e.g. strptime("2015-08-28T13:33:21Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000, and strptime("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000. See also strptime_local. + (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch. See also strptime_local. + Examples: + strptime("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000 + strptime("2015-08-28T13:33:21.345Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000 + strptime("1970-01-01 00:00:00 -0400", "%Y-%m-%d %H:%M:%S %z") = 14400 + strptime("1970-01-01 00:00:00 EET", "%Y-%m-%d %H:%M:%S %Z") = -7200 strptime_local (class=time #args=2) Like stpftime but consults the $TZ environment variable to get local time zone. + Examples: + strptime_local("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440758001 with TZ="Asia/Istanbul" + strptime_local("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440758001.345 with TZ="Asia/Istanbul" + strptime_local("2015-08-28 13:33:21", "%Y-%m-%d %H:%M:%S") = 1440758001 with TZ="Asia/Istanbul" sub - (class=string #args=3) Example: '$name=sub($name, "old", "new")' (replace once). + (class=string #args=3) '$name=sub($name, "old", "new")' (replace once). substr (class=string #args=3) substr is an alias for substr0. See also substr1. Miller is generally 1-up with all array and string indices, but, this is a backward-compatibility issue with Miller 5 and below. Arrays are new in Miller 6; the substr function is older. @@ -2385,13 +2445,15 @@ FUNCTIONS FOR FILTER/PUT unflatten (class=collections #args=2) Reverses flatten. Useful for nested JSON-like structures for non-JSON file formats like CSV. See also arrayify. - Example: unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. + Example: + unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. uptime (class=time #args=0) help string will go here urand (class=math #args=0) Floating-point numbers uniformly distributed on the unit interval. + Example: Int-valued example: '$n=floor(20+urand()*11)'. urand32 @@ -2886,5 +2948,5 @@ SEE ALSO - 2021-10-17 MILLER(1) + 2021-10-21 MILLER(1) diff --git a/docs6/src/manpage.txt b/docs6/src/manpage.txt index 8a71693f9..cd40881a1 100644 --- a/docs6/src/manpage.txt +++ b/docs6/src/manpage.txt @@ -171,20 +171,21 @@ FUNCTION LIST asserting_present asserting_string atan atan2 atanh bitcount boolean capitalize cbrt ceil clean_whitespace collapse_whitespace cos cosh depth dhms2fsec dhms2sec erf erfc every exp expm1 flatten float floor fmtnum fold - fsec2dhms fsec2hms get_keys get_values gmt2sec gsub haskey hexfmt hms2fsec - hms2sec hostname int invqnorm is_absent is_array is_bool is_boolean is_empty - is_empty_map is_error is_float is_int is_map is_nonempty_map is_not_array - is_not_empty is_not_map is_not_null is_null is_numeric is_present is_string - joink joinkv joinv json_parse json_stringify leafcount length localtime2sec - log log10 log1p logifit lstrip madd mapdiff mapexcept mapselect mapsum max md5 - mexp min mmul msub os pow qnorm reduce regextract regextract_or_else round - roundm rstrip sec2dhms sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime - select sgn sha1 sha256 sha512 sin sinh sort splita splitax splitkv splitkvx - splitnv splitnvx sqrt ssub strftime strftime_local string strip strlen - strptime strptime_local sub substr substr0 substr1 system systime systimeint - tan tanh tolower toupper truncate typeof unflatten uptime urand urand32 - urandint urandrange version ! != !=~ % & && * ** + - . .* .+ .- ./ / // < << - <= <=> == =~ > >= >> >>> ?: ?? ??? ^ ^^ | || ~ + fsec2dhms fsec2hms get_keys get_values gmt2localtime gmt2sec gsub haskey + hexfmt hms2fsec hms2sec hostname int invqnorm is_absent is_array is_bool + is_boolean is_empty is_empty_map is_error is_float is_int is_map + is_nonempty_map is_not_array is_not_empty is_not_map is_not_null is_null + is_numeric is_present is_string joink joinkv joinv json_parse json_stringify + leafcount length localtime2gmt localtime2sec log log10 log1p logifit lstrip + madd mapdiff mapexcept mapselect mapsum max md5 mexp min mmul msub os pow + qnorm reduce regextract regextract_or_else round roundm rstrip sec2dhms + sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime select sgn sha1 sha256 + sha512 sin sinh sort splita splitax splitkv splitkvx splitnv splitnvx sqrt + ssub strftime strftime_local string strip strlen strptime strptime_local sub + substr substr0 substr1 system systime systimeint tan tanh tolower toupper + truncate typeof unflatten uptime urand urand32 urandint urandrange version ! + != !=~ % & && * ** + - . .* .+ .- ./ / // < << <= <=> == =~ > >= >> >>> ?: ?? + ??? ^ ^^ | || ~ COMMENTS-IN-DATA FLAGS Miller lets you put comments in your data, such as @@ -449,6 +450,8 @@ MISCELLANEOUS FLAGS the `fmtnum` function and the `format-values` verb. --seed {n} with `n` of the form `12345678` or `0xcafefeed`. For `put`/`filter` `urand`, `urandint`, and `urand32`. + --tz {timezone} Specify timezone, overriding `$TZ` environment + variable (if any). -I Process files in-place. For each file name on the command line, output is written to a temp file in the same directory, which is then renamed over the @@ -1865,6 +1868,7 @@ FUNCTIONS FOR FILTER/PUT any (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for any array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: any([10,20,30], func(e) {return $index == e}) Map example: any({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) @@ -1873,6 +1877,7 @@ FUNCTIONS FOR FILTER/PUT apply (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, applies the function to each element of the array/map. For arrays, the function should take one argument, for array element; it should return a new element. For maps, it should take two arguments, for map-element key and value; it should return a new key-value pair (i.e. a single-entry map). + Examples: Array example: apply([1,2,3,4,5], func(e) {return e ** 3}) returns [1, 8, 27, 64, 125]. Map example: apply({"a":1, "b":3, "c":5}, func(k,v) {return {toupper(k): v ** 2}}) returns {"A": 1, "B":9, "C": 25}", @@ -1996,6 +2001,7 @@ FUNCTIONS FOR FILTER/PUT every (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for every array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: every(["a", "b", "c"], func(e) {return $[e] >= 0}) Map example: every({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) @@ -2007,8 +2013,9 @@ FUNCTIONS FOR FILTER/PUT flatten (class=collections #args=3) Flattens multi-level maps to single-level ones. Useful for nested JSON-like structures for non-JSON file formats like CSV. - Example: flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. - Example: flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. + Examples: + flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. + flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. Two-argument version: flatten($*, ".") is the same as flatten("", ".", $*). float @@ -2022,6 +2029,7 @@ FUNCTIONS FOR FILTER/PUT fold (class=higher-order-functions #args=3) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is taken from the third argument. + Examples: Array example: fold([1,2,3,4,5], func(acc,e) {return acc + e**3}, 10000) returns 10225. Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": accv+ev**2}}, {"sum":10000}) returns 10035. @@ -2037,11 +2045,18 @@ FUNCTIONS FOR FILTER/PUT get_values (class=collections #args=1) Returns array of keys of map or array -- in the latter case, returns a copy of the array + gmt2localtime + (class=time #args=1) Convert from a GMT-time string to a local-time string, consulting $TZ + Example: + gmt2localtime("1999-12-31T22:00:00Z") = "2000-01-01 00:00:00" with TZ="Asia/Istanbul" + gmt2sec (class=time #args=1) Parses GMT timestamp as integer seconds since the epoch. + Example: + gmt2sec("2001-02-03T04:05:06Z") = 981173106 gsub - (class=string #args=3) Example: '$name=gsub($name, "old", "new")' (replace all). + (class=string #args=3) '$name=gsub($name, "old", "new")' (replace all). haskey (class=collections #args=2) True/false if map has/hasn't key, e.g. 'haskey($*, "a")' or 'haskey(mymap, mykey)', or true/false if array index is in bounds / out of bounds. Error if 1st argument is not a map or array. Note -n..-1 alias to 1..n in Miller arrays. @@ -2123,13 +2138,15 @@ FUNCTIONS FOR FILTER/PUT joink (class=conversion #args=2) Makes string from map/array keys. - Example: joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". - Example: joink([1,2,3], ",") = "1,2,3". + Examples: + joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". + joink([1,2,3], ",") = "1,2,3". joinkv (class=conversion #args=3) Makes string from map/array key-value pairs. - Example: joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" - Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" + Examples: + joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" + joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" joinv (class=conversion #args=2) Makes string from map/array values. joinv([3,4,5], ",") = "3,4,5" joinv({"a":3,"b":4,"c":5}, ",") = "3,4,5" @@ -2146,8 +2163,15 @@ FUNCTIONS FOR FILTER/PUT length (class=collections #args=1) Counts number of top-level entries in array/map. Scalars have length 1. + localtime2gmt + (class=time #args=1) Convert from a local-time string to a GMT-time string, consulting $TZ + Example: + localtime2gmt("2000-01-01 00:00:00") = "1999-12-31T22:00:00Z" with TZ="Asia/Istanbul" + localtime2sec (class=time #args=1) Parses local timestamp as integer seconds since the epoch. Consults $TZ environment variable. + Example: + localtime2sec("2001-02-03 04:05:06") = 981165906 with TZ="Asia/Istanbul" log (class=math #args=1) Natural (base-e) logarithm. @@ -2208,14 +2232,15 @@ FUNCTIONS FOR FILTER/PUT reduce (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element, and return the accumulated element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is the first element for arrays, or the first element's key-value pair for maps. + Examples: Array example: reduce([1,2,3,4,5], func(acc,e) {return acc + e**3}) returns 225. Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_of_squares": accv + ev**2}}) returns {"sum_of_squares": 35}. regextract - (class=string #args=2) Example: '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' + (class=string #args=2) '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' regextract_or_else - (class=string #args=3) Example: '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' + (class=string #args=3) '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' round (class=math #args=1) Round to nearest integer. @@ -2230,22 +2255,35 @@ FUNCTIONS FOR FILTER/PUT (class=time #args=1) Formats integer seconds as in sec2dhms(500000) = "5d18h53m20s" sec2gmt - (class=time #args=1,2) Formats seconds since epoch (integer part) as GMT timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch as GMT timestamp. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part. + Examples: + sec2gmt(1234567890) = "2009-02-13T23:31:30Z" + sec2gmt(1234567890.123456) = "2009-02-13T23:31:30Z" + sec2gmt(1234567890.123456, 6) = "2009-02-13T23:31:30.123456Z" sec2gmtdate - (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. + (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date. Leaves non-numbers as-is. + Example: + sec2gmtdate(1440768801.7) = "2015-08-28". sec2hms (class=time #args=1) Formats integer seconds as in sec2hms(5000) = "01:23:20" sec2localdate - (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. Consults $TZ environment variable. + (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date. Leaves non-numbers as-is. Consults $TZ environment variable. + Example: + sec2localdate(1440768801.7) = "2015-08-28" with TZ="Asia/Istanbul" sec2localtime - (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp. Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + Examples: + sec2localtime(1234567890) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" + sec2localtime(1234567890.123456) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" + sec2localtime(1234567890.123456, 6) = "2009-02-14 01:31:30.123456" with TZ="Asia/Istanbul" select (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, includes each input element in the output if the function returns true. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: select([1,2,3,4,5], func(e) {return e >= 3}) returns [3, 4, 5]. Map example: select({"a":1, "b":3, "c":5}, func(k,v) {return v >= 3}) returns {"b":3, "c": 5}. @@ -2269,32 +2307,39 @@ FUNCTIONS FOR FILTER/PUT sort (class=higher-order-functions #args=1-2) Given a map or array as first argument and string flags or function as optional second argument, returns a sorted copy of the input. With one argument, sorts array elements naturally, and maps naturally by map keys. If the second argument is a string, it can contain any of "f" for lexical (default "n" for natural/numeric), "), "c" for case-folded lexical, and "r" for reversed/descending sort. If the second argument is a function, then for arrays it should take two arguments a and b, returning < 0, 0, or > 0 as a < b, a == b, or a > b respectively; for maps the function should take four arguments ak, av, bk, and bv, again returning < 0, 0, or > 0, using a and b's keys and values. + Examples: Array example: sort([5,2,3,1,4], func(a,b) {return b <=> a}) returns [5,4,3,2,1]. Map example: sort({"c":2,"a":3,"b":1}, func(ak,av,bk,bv) {return bv <=> av}) returns {"a":3,"c":2,"b":1}. splita (class=conversion #args=2) Splits string into array with type inference. - Example: splita("3,4,5", ",") = [3,4,5] + Example: + splita("3,4,5", ",") = [3,4,5] splitax (class=conversion #args=2) Splits string into array without type inference. - Example: splita("3,4,5", ",") = ["3","4","5"] + Example: + splita("3,4,5", ",") = ["3","4","5"] splitkv (class=conversion #args=3) Splits string by separators into map with type inference. - Example: splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} + Example: + splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} splitkvx (class=conversion #args=3) Splits string by separators into map without type inference (keys and values are strings). - Example: splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} + Example: + splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} splitnv (class=conversion #args=2) Splits string by separator into integer-indexed map with type inference. - Example: splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} + Example: + splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} splitnvx (class=conversion #args=2) Splits string by separator into integer-indexed map without type inference (values are strings). - Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} + Example: + splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} sqrt (class=math #args=1) Square root. @@ -2303,10 +2348,16 @@ FUNCTIONS FOR FILTER/PUT (class=string #args=3) Like sub but does no regexing. No characters are special. strftime - (class=time #args=2) Formats seconds since the epoch as timestamp, e.g. strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z", and strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z". Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. + (class=time #args=2) Formats seconds since the epoch as timestamp. Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. + Examples: + strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z" + strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z" strftime_local (class=time #args=2) Like strftime but consults the $TZ environment variable to get local time zone. + Examples: + strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%S %z") = "2015-08-28 16:33:21 +0300" with TZ="Asia/Istanbul" + strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%3S %z") = "2015-08-28 16:33:21.700 +0300" with TZ="Asia/Istanbul" string (class=conversion #args=1) Convert int/float/bool/string/array/map to string. @@ -2318,13 +2369,22 @@ FUNCTIONS FOR FILTER/PUT (class=string #args=1) String length. strptime - (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch, e.g. strptime("2015-08-28T13:33:21Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000, and strptime("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000. See also strptime_local. + (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch. See also strptime_local. + Examples: + strptime("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000 + strptime("2015-08-28T13:33:21.345Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000 + strptime("1970-01-01 00:00:00 -0400", "%Y-%m-%d %H:%M:%S %z") = 14400 + strptime("1970-01-01 00:00:00 EET", "%Y-%m-%d %H:%M:%S %Z") = -7200 strptime_local (class=time #args=2) Like stpftime but consults the $TZ environment variable to get local time zone. + Examples: + strptime_local("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440758001 with TZ="Asia/Istanbul" + strptime_local("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440758001.345 with TZ="Asia/Istanbul" + strptime_local("2015-08-28 13:33:21", "%Y-%m-%d %H:%M:%S") = 1440758001 with TZ="Asia/Istanbul" sub - (class=string #args=3) Example: '$name=sub($name, "old", "new")' (replace once). + (class=string #args=3) '$name=sub($name, "old", "new")' (replace once). substr (class=string #args=3) substr is an alias for substr0. See also substr1. Miller is generally 1-up with all array and string indices, but, this is a backward-compatibility issue with Miller 5 and below. Arrays are new in Miller 6; the substr function is older. @@ -2364,13 +2424,15 @@ FUNCTIONS FOR FILTER/PUT unflatten (class=collections #args=2) Reverses flatten. Useful for nested JSON-like structures for non-JSON file formats like CSV. See also arrayify. - Example: unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. + Example: + unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. uptime (class=time #args=0) help string will go here urand (class=math #args=0) Floating-point numbers uniformly distributed on the unit interval. + Example: Int-valued example: '$n=floor(20+urand()*11)'. urand32 @@ -2865,4 +2927,4 @@ SEE ALSO - 2021-10-17 MILLER(1) + 2021-10-21 MILLER(1) diff --git a/docs6/src/online-help.md b/docs6/src/online-help.md index dd3045bea..a539958ea 100644 --- a/docs6/src/online-help.md +++ b/docs6/src/online-help.md @@ -240,7 +240,8 @@ No exact match for "split". Inexact matches:
 splita  (class=conversion #args=2) Splits string into array with type inference.
-Example: splita("3,4,5", ",") = [3,4,5]
+Example:
+splita("3,4,5", ",") = [3,4,5]
 
Etc. diff --git a/docs6/src/reference-dsl-builtin-functions.md b/docs6/src/reference-dsl-builtin-functions.md index d2265caec..62a9b30c9 100644 --- a/docs6/src/reference-dsl-builtin-functions.md +++ b/docs6/src/reference-dsl-builtin-functions.md @@ -76,7 +76,7 @@ is 2. Unary operators such as `!` and `~` show argument-count of 1; the ternary * [**Math functions**](#math-functions): [abs](#abs), [acos](#acos), [acosh](#acosh), [asin](#asin), [asinh](#asinh), [atan](#atan), [atan2](#atan2), [atanh](#atanh), [cbrt](#cbrt), [ceil](#ceil), [cos](#cos), [cosh](#cosh), [erf](#erf), [erfc](#erfc), [exp](#exp), [expm1](#expm1), [floor](#floor), [invqnorm](#invqnorm), [log](#log), [log10](#log10), [log1p](#log1p), [logifit](#logifit), [max](#max), [min](#min), [qnorm](#qnorm), [round](#round), [roundm](#roundm), [sgn](#sgn), [sin](#sin), [sinh](#sinh), [sqrt](#sqrt), [tan](#tan), [tanh](#tanh), [urand](#urand), [urand32](#urand32), [urandint](#urandint), [urandrange](#urandrange). * [**String functions**](#string-functions): [capitalize](#capitalize), [clean_whitespace](#clean_whitespace), [collapse_whitespace](#collapse_whitespace), [gsub](#gsub), [lstrip](#lstrip), [regextract](#regextract), [regextract_or_else](#regextract_or_else), [rstrip](#rstrip), [ssub](#ssub), [strip](#strip), [strlen](#strlen), [sub](#sub), [substr](#substr), [substr0](#substr0), [substr1](#substr1), [tolower](#tolower), [toupper](#toupper), [truncate](#truncate), [\.](#dot). * [**System functions**](#system-functions): [hostname](#hostname), [os](#os), [system](#system), [version](#version). -* [**Time functions**](#time-functions): [dhms2fsec](#dhms2fsec), [dhms2sec](#dhms2sec), [fsec2dhms](#fsec2dhms), [fsec2hms](#fsec2hms), [gmt2sec](#gmt2sec), [hms2fsec](#hms2fsec), [hms2sec](#hms2sec), [localtime2sec](#localtime2sec), [sec2dhms](#sec2dhms), [sec2gmt](#sec2gmt), [sec2gmtdate](#sec2gmtdate), [sec2hms](#sec2hms), [sec2localdate](#sec2localdate), [sec2localtime](#sec2localtime), [strftime](#strftime), [strftime_local](#strftime_local), [strptime](#strptime), [strptime_local](#strptime_local), [systime](#systime), [systimeint](#systimeint), [uptime](#uptime). +* [**Time functions**](#time-functions): [dhms2fsec](#dhms2fsec), [dhms2sec](#dhms2sec), [fsec2dhms](#fsec2dhms), [fsec2hms](#fsec2hms), [gmt2localtime](#gmt2localtime), [gmt2sec](#gmt2sec), [hms2fsec](#hms2fsec), [hms2sec](#hms2sec), [localtime2gmt](#localtime2gmt), [localtime2sec](#localtime2sec), [sec2dhms](#sec2dhms), [sec2gmt](#sec2gmt), [sec2gmtdate](#sec2gmtdate), [sec2hms](#sec2hms), [sec2localdate](#sec2localdate), [sec2localtime](#sec2localtime), [strftime](#strftime), [strftime_local](#strftime_local), [strptime](#strptime), [strptime_local](#strptime_local), [systime](#systime), [systimeint](#systimeint), [uptime](#uptime). * [**Typing functions**](#typing-functions): [asserting_absent](#asserting_absent), [asserting_array](#asserting_array), [asserting_bool](#asserting_bool), [asserting_boolean](#asserting_boolean), [asserting_empty](#asserting_empty), [asserting_empty_map](#asserting_empty_map), [asserting_error](#asserting_error), [asserting_float](#asserting_float), [asserting_int](#asserting_int), [asserting_map](#asserting_map), [asserting_nonempty_map](#asserting_nonempty_map), [asserting_not_array](#asserting_not_array), [asserting_not_empty](#asserting_not_empty), [asserting_not_map](#asserting_not_map), [asserting_not_null](#asserting_not_null), [asserting_null](#asserting_null), [asserting_numeric](#asserting_numeric), [asserting_present](#asserting_present), [asserting_string](#asserting_string), [is_absent](#is_absent), [is_array](#is_array), [is_bool](#is_bool), [is_boolean](#is_boolean), [is_empty](#is_empty), [is_empty_map](#is_empty_map), [is_error](#is_error), [is_float](#is_float), [is_int](#is_int), [is_map](#is_map), [is_nonempty_map](#is_nonempty_map), [is_not_array](#is_not_array), [is_not_empty](#is_not_empty), [is_not_map](#is_not_map), [is_not_null](#is_not_null), [is_null](#is_null), [is_numeric](#is_numeric), [is_present](#is_present), [is_string](#is_string), [typeof](#typeof). ## Arithmetic functions @@ -381,8 +381,9 @@ depth (class=collections #args=1) Prints maximum depth of map/array. Scalars ha ### flatten
 flatten  (class=collections #args=3) Flattens multi-level maps to single-level ones. Useful for nested JSON-like structures for non-JSON file formats like CSV.
-Example: flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}.
-Example: flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}.
+Examples:
+flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}.
+flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}.
 Two-argument version: flatten($*, ".") is the same as flatten("", ".", $*).
 
@@ -456,7 +457,8 @@ mapsum (class=collections #args=variadic) With 0 args, returns empty map. With ### unflatten
 unflatten  (class=collections #args=2) Reverses flatten. Useful for nested JSON-like structures for non-JSON file formats like CSV.  See also arrayify.
-Example: unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}.
+Example:
+unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}.
 
## Conversion functions @@ -495,16 +497,18 @@ int (class=conversion #args=1) Convert int/float/bool/string to int. ### joink
 joink  (class=conversion #args=2) Makes string from map/array keys.
-Example: joink({"a":3,"b":4,"c":5}, ",") = "a,b,c".
-Example: joink([1,2,3], ",") = "1,2,3".
+Examples:
+joink({"a":3,"b":4,"c":5}, ",") = "a,b,c".
+joink([1,2,3], ",") = "1,2,3".
 
### joinkv
 joinkv  (class=conversion #args=3) Makes string from map/array key-value pairs.
-Example: joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5"
-Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5"
+Examples:
+joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5"
+joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5"
 
@@ -517,42 +521,48 @@ joinv (class=conversion #args=2) Makes string from map/array values. joinv([3, ### splita
 splita  (class=conversion #args=2) Splits string into array with type inference.
-Example: splita("3,4,5", ",") = [3,4,5]
+Example:
+splita("3,4,5", ",") = [3,4,5]
 
### splitax
 splitax  (class=conversion #args=2) Splits string into array without type inference.
-Example: splita("3,4,5", ",") = ["3","4","5"]
+Example:
+splita("3,4,5", ",") = ["3","4","5"]
 
### splitkv
 splitkv  (class=conversion #args=3) Splits string by separators into map with type inference.
-Example: splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5}
+Example:
+splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5}
 
### splitkvx
 splitkvx  (class=conversion #args=3) Splits string by separators into map without type inference (keys and values are strings).
-Example: splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"}
+Example:
+splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"}
 
### splitnv
 splitnv  (class=conversion #args=2) Splits string by separator into integer-indexed map with type inference.
-Example: splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"}
+Example:
+splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"}
 
### splitnvx
 splitnvx  (class=conversion #args=2) Splits string by separator into integer-indexed map without type inference (values are strings).
-Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"}
+Example:
+splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"}
 
@@ -593,6 +603,7 @@ sha512 (class=hashing #args=1) SHA512 hash. ### any
 any  (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for any array/map element, false otherwise.  For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean.
+Examples:
 Array example: any([10,20,30], func(e) {return $index == e})
 Map example: any({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v})
 
@@ -601,6 +612,7 @@ Map example: any({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) ### apply
 apply  (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, applies the function to each element of the array/map.  For arrays, the function should take one argument, for array element; it should return a new element. For maps, it should take two arguments, for map-element key and value; it should return a new key-value pair (i.e. a single-entry map).
+Examples:
 Array example: apply([1,2,3,4,5], func(e) {return e ** 3}) returns [1, 8, 27, 64, 125].
 Map example: apply({"a":1, "b":3, "c":5}, func(k,v) {return {toupper(k): v ** 2}}) returns {"A": 1, "B":9, "C": 25}",
 
@@ -609,6 +621,7 @@ Map example: apply({"a":1, "b":3, "c":5}, func(k,v) {return {toupper(k): v ** 2} ### every
 every  (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for every array/map element, false otherwise.  For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean.
+Examples:
 Array example: every(["a", "b", "c"], func(e) {return $[e] >= 0})
 Map example: every({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v})
 
@@ -617,6 +630,7 @@ Map example: every({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) ### fold
 fold  (class=higher-order-functions #args=3) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is taken from the third argument.
+Examples:
 Array example: fold([1,2,3,4,5], func(acc,e) {return acc + e**3}, 10000) returns 10225.
 Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": accv+ev**2}}, {"sum":10000}) returns 10035.
 
@@ -625,6 +639,7 @@ Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": ### reduce
 reduce  (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element, and return the accumulated element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is the first element for arrays, or the first element's key-value pair for maps.
+Examples:
 Array example: reduce([1,2,3,4,5], func(acc,e) {return acc + e**3}) returns 225.
 Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_of_squares": accv + ev**2}}) returns {"sum_of_squares": 35}.
 
@@ -633,6 +648,7 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ ### select
 select  (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, includes each input element in the output if the function returns true. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean.
+Examples:
 Array example: select([1,2,3,4,5], func(e) {return e >= 3}) returns [3, 4, 5].
 Map example: select({"a":1, "b":3, "c":5}, func(k,v) {return v >= 3}) returns {"b":3, "c": 5}.
 
@@ -641,6 +657,7 @@ Map example: select({"a":1, "b":3, "c":5}, func(k,v) {return v >= 3}) returns {" ### sort
 sort  (class=higher-order-functions #args=1-2) Given a map or array as first argument and string flags or function as optional second argument, returns a sorted copy of the input. With one argument, sorts array elements naturally, and maps naturally by map keys. If the second argument is a string, it can contain any of "f" for lexical (default "n" for natural/numeric), "), "c" for case-folded lexical, and "r" for reversed/descending sort. If the second argument is a function, then for arrays it should take two arguments a and b, returning < 0, 0, or > 0 as a < b, a == b, or a > b respectively; for maps the function should take four arguments ak, av, bk, and bv, again returning < 0, 0, or > 0, using a and b's keys and values.
+Examples:
 Array example: sort([5,2,3,1,4], func(a,b) {return b <=> a}) returns [5,4,3,2,1].
 Map example: sort({"c":2,"a":3,"b":1}, func(ak,av,bk,bv) {return bv <=> av}) returns {"a":3,"c":2,"b":1}.
 
@@ -849,6 +866,7 @@ tanh (class=math #args=1) Hyperbolic tangent. ### urand
 urand  (class=math #args=0) Floating-point numbers uniformly distributed on the unit interval.
+Example:
 Int-valued example: '$n=floor(20+urand()*11)'.
 
@@ -893,7 +911,7 @@ collapse_whitespace (class=string #args=1) Strip repeated whitespace from strin ### gsub
-gsub  (class=string #args=3) Example: '$name=gsub($name, "old", "new")' (replace all).
+gsub  (class=string #args=3) '$name=gsub($name, "old", "new")' (replace all).
 
@@ -905,13 +923,13 @@ lstrip (class=string #args=1) Strip leading whitespace from string. ### regextract
-regextract  (class=string #args=2) Example: '$name=regextract($name, "[A-Z]{3}[0-9]{2}")'
+regextract  (class=string #args=2) '$name=regextract($name, "[A-Z]{3}[0-9]{2}")'
 
### regextract_or_else
-regextract_or_else  (class=string #args=3) Example: '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")'
+regextract_or_else  (class=string #args=3) '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")'
 
@@ -941,7 +959,7 @@ strlen (class=string #args=1) String length. ### sub
-sub  (class=string #args=3) Example: '$name=sub($name, "old", "new")' (replace once).
+sub  (class=string #args=3) '$name=sub($name, "old", "new")' (replace once).
 
@@ -1040,9 +1058,19 @@ fsec2hms (class=time #args=1) Formats floating-point seconds as in fsec2hms(500 +### gmt2localtime +
+gmt2localtime  (class=time #args=1) Convert from a GMT-time string to a local-time string, consulting $TZ
+Example:
+gmt2localtime("1999-12-31T22:00:00Z") = "2000-01-01 00:00:00" with TZ="Asia/Istanbul"
+
+ + ### gmt2sec
 gmt2sec  (class=time #args=1) Parses GMT timestamp as integer seconds since the epoch.
+Example:
+gmt2sec("2001-02-03T04:05:06Z") = 981173106
 
@@ -1058,9 +1086,19 @@ hms2sec (class=time #args=1) Recovers integer seconds as in hms2sec("01:23:20") +### localtime2gmt +
+localtime2gmt  (class=time #args=1) Convert from a local-time string to a GMT-time string, consulting $TZ
+Example:
+localtime2gmt("2000-01-01 00:00:00") = "1999-12-31T22:00:00Z" with TZ="Asia/Istanbul"
+
+ + ### localtime2sec
 localtime2sec  (class=time #args=1) Parses local timestamp as integer seconds since the epoch. Consults $TZ environment variable.
+Example:
+localtime2sec("2001-02-03 04:05:06") = 981165906 with TZ="Asia/Istanbul"
 
@@ -1072,13 +1110,19 @@ sec2dhms (class=time #args=1) Formats integer seconds as in sec2dhms(500000) = ### sec2gmt
-sec2gmt  (class=time #args=1,2) Formats seconds since epoch (integer part) as GMT timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z".  Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part
+sec2gmt  (class=time #args=1,2) Formats seconds since epoch as GMT timestamp. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part.
+Examples:
+sec2gmt(1234567890)           = "2009-02-13T23:31:30Z"
+sec2gmt(1234567890.123456)    = "2009-02-13T23:31:30Z"
+sec2gmt(1234567890.123456, 6) = "2009-02-13T23:31:30.123456Z"
 
### sec2gmtdate
-sec2gmtdate  (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28".  Leaves non-numbers as-is.
+sec2gmtdate  (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date.  Leaves non-numbers as-is.
+Example:
+sec2gmtdate(1440768801.7) = "2015-08-28".
 
@@ -1090,37 +1134,58 @@ sec2hms (class=time #args=1) Formats integer seconds as in sec2hms(5000) = "01: ### sec2localdate
-sec2localdate  (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28".  Leaves non-numbers as-is. Consults $TZ environment variable.
+sec2localdate  (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date.  Leaves non-numbers as-is. Consults $TZ environment variable.
+Example:
+sec2localdate(1440768801.7) = "2015-08-28" with TZ="Asia/Istanbul"
 
### sec2localtime
-sec2localtime  (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z".  Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part
+sec2localtime  (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp.  Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part
+Examples:
+sec2localtime(1234567890)           = "2009-02-14 01:31:30"        with TZ="Asia/Istanbul"
+sec2localtime(1234567890.123456)    = "2009-02-14 01:31:30"        with TZ="Asia/Istanbul"
+sec2localtime(1234567890.123456, 6) = "2009-02-14 01:31:30.123456" with TZ="Asia/Istanbul"
 
### strftime
-strftime  (class=time #args=2) Formats seconds since the epoch as timestamp, e.g.  strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z", and strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z".  Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local.
+strftime  (class=time #args=2) Formats seconds since the epoch as timestamp. Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local.
+Examples:
+strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ")  = "2015-08-28T13:33:21Z"
+strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z"
 
### strftime_local
 strftime_local  (class=time #args=2) Like strftime but consults the $TZ environment variable to get local time zone.
+Examples:
+strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%S %z")  = "2015-08-28 16:33:21 +0300" with TZ="Asia/Istanbul"
+strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%3S %z") = "2015-08-28 16:33:21.700 +0300" with TZ="Asia/Istanbul"
 
### strptime
-strptime  (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch, e.g. strptime("2015-08-28T13:33:21Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000, and  strptime("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000.  See also strptime_local.
+strptime  (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch. See also strptime_local.
+Examples:
+strptime("2015-08-28T13:33:21Z",      "%Y-%m-%dT%H:%M:%SZ")   = 1440768801.000000
+strptime("2015-08-28T13:33:21.345Z",  "%Y-%m-%dT%H:%M:%SZ")   = 1440768801.345000
+strptime("1970-01-01 00:00:00 -0400", "%Y-%m-%d %H:%M:%S %z") = 14400
+strptime("1970-01-01 00:00:00 EET",   "%Y-%m-%d %H:%M:%S %Z") = -7200
 
### strptime_local
 strptime_local  (class=time #args=2) Like stpftime but consults the $TZ environment variable to get local time zone.
+Examples:
+strptime_local("2015-08-28T13:33:21Z",    "%Y-%m-%dT%H:%M:%SZ") = 1440758001     with TZ="Asia/Istanbul"
+strptime_local("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440758001.345 with TZ="Asia/Istanbul"
+strptime_local("2015-08-28 13:33:21",    "%Y-%m-%d %H:%M:%S")   = 1440758001     with TZ="Asia/Istanbul"
 
diff --git a/docs6/src/reference-main-flag-list.md b/docs6/src/reference-main-flag-list.md index fcba3fe55..eee2afc83 100644 --- a/docs6/src/reference-main-flag-list.md +++ b/docs6/src/reference-main-flag-list.md @@ -331,6 +331,8 @@ These are flags which don't fit into any other category. `: E.g. `%.18f`, `%.0f`, `%9.6e`. Please use sprintf-style codes for floating-point nummbers. If not specified, default formatting is used. See also the `fmtnum` function and the `format-values` verb. * `--seed {n} `: with `n` of the form `12345678` or `0xcafefeed`. For `put`/`filter` `urand`, `urandint`, and `urand32`. +* `--tz {timezone} +`: Specify timezone, overriding `$TZ` environment variable (if any). * `-I `: Process files in-place. For each file name on the command line, output is written to a temp file in the same directory, which is then renamed over the original. Each file is processed in isolation: if the output format is CSV, CSV headers will be present in each output file, statistics are only over each file's own records; and so on. * `-n diff --git a/go/build b/go/build index eda53e27a..356483d22 100755 --- a/go/build +++ b/go/build @@ -16,6 +16,8 @@ if [ "$do_wips" = "false" ]; then set -euo pipefail fi +export TZ="" + echo ================================================================ echo BUILD go build diff --git a/go/mktags b/go/mktags index e35854eee..5f2570e5c 100755 --- a/go/mktags +++ b/go/mktags @@ -11,5 +11,5 @@ set -euo pipefail # # See also https://stackoverflow.com/questions/8204367/ctag-database-for-go -ctags -f gosource.tags -R `pwd`/src +ctags -f gosource.tags -R `pwd`/src `pwd`/github mv gosource.tags tags diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/expout b/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/expout deleted file mode 100644 index 8b7a402cd..000000000 --- a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/expout +++ /dev/null @@ -1,11 +0,0 @@ -a b c d tz -2017-02-18 23:00:00 1487466000 2017-02-18T23:00:00Z 2017-02-18 America/Sao_Paulo -2017-02-18 23:59:59 1487469599 2017-02-18T23:59:59Z 2017-02-18 America/Sao_Paulo -2017-02-19 00:00:00 1487473200 2017-02-19T00:00:00Z 2017-02-19 America/Sao_Paulo -2017-02-19 00:30:00 1487475000 2017-02-19T00:30:00Z 2017-02-19 America/Sao_Paulo -2017-02-19 01:00:00 1487476800 2017-02-19T01:00:00Z 2017-02-19 America/Sao_Paulo -2017-10-14 23:00:00 1508032800 2017-10-14T23:00:00Z 2017-10-14 America/Sao_Paulo -2017-10-14 23:59:59 1508036399 2017-10-14T23:59:59Z 2017-10-14 America/Sao_Paulo -2017-10-15 00:00:00 1508032800 2017-10-14T23:00:00Z 2017-10-14 America/Sao_Paulo -2017-10-15 00:30:00 1508034600 2017-10-14T23:30:00Z 2017-10-14 America/Sao_Paulo -2017-10-15 01:00:00 1508036400 2017-10-15T01:00:00Z 2017-10-15 America/Sao_Paulo diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/expout b/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/expout deleted file mode 100644 index 7f9e355af..000000000 --- a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/expout +++ /dev/null @@ -1,16 +0,0 @@ -a b c d tz -2017-02-14 00:00:00 1487037600 2017-02-14T00:00:00Z 2017-02-14 America/Sao_Paulo -2017-02-15 00:00:00 1487124000 2017-02-15T00:00:00Z 2017-02-15 America/Sao_Paulo -2017-02-16 00:00:00 1487210400 2017-02-16T00:00:00Z 2017-02-16 America/Sao_Paulo -2017-02-17 00:00:00 1487296800 2017-02-17T00:00:00Z 2017-02-17 America/Sao_Paulo -2017-02-18 00:00:00 1487383200 2017-02-18T00:00:00Z 2017-02-18 America/Sao_Paulo -2017-02-19 00:00:00 1487473200 2017-02-19T00:00:00Z 2017-02-19 America/Sao_Paulo -2017-02-20 00:00:00 1487559600 2017-02-20T00:00:00Z 2017-02-20 America/Sao_Paulo -2017-10-12 00:00:00 1507777200 2017-10-12T00:00:00Z 2017-10-12 America/Sao_Paulo -2017-10-13 00:00:00 1507863600 2017-10-13T00:00:00Z 2017-10-13 America/Sao_Paulo -2017-10-14 00:00:00 1507950000 2017-10-14T00:00:00Z 2017-10-14 America/Sao_Paulo -2017-10-15 00:00:00 1508032800 2017-10-14T23:00:00Z 2017-10-14 America/Sao_Paulo -2017-10-16 00:00:00 1508119200 2017-10-16T00:00:00Z 2017-10-16 America/Sao_Paulo -2017-10-17 00:00:00 1508205600 2017-10-17T00:00:00Z 2017-10-17 America/Sao_Paulo -2017-10-18 00:00:00 1508292000 2017-10-18T00:00:00Z 2017-10-18 America/Sao_Paulo -2017-10-19 00:00:00 1508378400 2017-10-19T00:00:00Z 2017-10-19 America/Sao_Paulo diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/cmd b/go/regtest/cases/dsl-local-date-time-functions/0001/cmd similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/cmd rename to go/regtest/cases/dsl-local-date-time-functions/0001/cmd diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/env b/go/regtest/cases/dsl-local-date-time-functions/0001/env similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/env rename to go/regtest/cases/dsl-local-date-time-functions/0001/env diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/experr b/go/regtest/cases/dsl-local-date-time-functions/0001/experr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/experr rename to go/regtest/cases/dsl-local-date-time-functions/0001/experr diff --git a/go/regtest/cases/dsl-local-date-time-functions/0001/expout b/go/regtest/cases/dsl-local-date-time-functions/0001/expout new file mode 100644 index 000000000..7dc1aad4d --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/0001/expout @@ -0,0 +1,11 @@ +a b c d tz +2017-02-18 23:00:00 1487466000 2017-02-18 23:00:00 2017-02-18 America/Sao_Paulo +2017-02-18 23:59:59 1487469599 2017-02-18 23:59:59 2017-02-18 America/Sao_Paulo +2017-02-19 00:00:00 1487473200 2017-02-19 00:00:00 2017-02-19 America/Sao_Paulo +2017-02-19 00:30:00 1487475000 2017-02-19 00:30:00 2017-02-19 America/Sao_Paulo +2017-02-19 01:00:00 1487476800 2017-02-19 01:00:00 2017-02-19 America/Sao_Paulo +2017-10-14 23:00:00 1508032800 2017-10-14 23:00:00 2017-10-14 America/Sao_Paulo +2017-10-14 23:59:59 1508036399 2017-10-14 23:59:59 2017-10-14 America/Sao_Paulo +2017-10-15 00:00:00 1508032800 2017-10-14 23:00:00 2017-10-14 America/Sao_Paulo +2017-10-15 00:30:00 1508034600 2017-10-14 23:30:00 2017-10-14 America/Sao_Paulo +2017-10-15 01:00:00 1508036400 2017-10-15 01:00:00 2017-10-15 America/Sao_Paulo diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/input b/go/regtest/cases/dsl-local-date-time-functions/0001/input similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/input rename to go/regtest/cases/dsl-local-date-time-functions/0001/input diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/mlr b/go/regtest/cases/dsl-local-date-time-functions/0001/mlr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0001/mlr rename to go/regtest/cases/dsl-local-date-time-functions/0001/mlr diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/cmd b/go/regtest/cases/dsl-local-date-time-functions/0002/cmd similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/cmd rename to go/regtest/cases/dsl-local-date-time-functions/0002/cmd diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/env b/go/regtest/cases/dsl-local-date-time-functions/0002/env similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/env rename to go/regtest/cases/dsl-local-date-time-functions/0002/env diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/experr b/go/regtest/cases/dsl-local-date-time-functions/0002/experr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/experr rename to go/regtest/cases/dsl-local-date-time-functions/0002/experr diff --git a/go/regtest/cases/dsl-local-date-time-functions/0002/expout b/go/regtest/cases/dsl-local-date-time-functions/0002/expout new file mode 100644 index 000000000..ce0add8f4 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/0002/expout @@ -0,0 +1,16 @@ +a b c d tz +2017-02-14 00:00:00 1487037600 2017-02-14 00:00:00 2017-02-14 America/Sao_Paulo +2017-02-15 00:00:00 1487124000 2017-02-15 00:00:00 2017-02-15 America/Sao_Paulo +2017-02-16 00:00:00 1487210400 2017-02-16 00:00:00 2017-02-16 America/Sao_Paulo +2017-02-17 00:00:00 1487296800 2017-02-17 00:00:00 2017-02-17 America/Sao_Paulo +2017-02-18 00:00:00 1487383200 2017-02-18 00:00:00 2017-02-18 America/Sao_Paulo +2017-02-19 00:00:00 1487473200 2017-02-19 00:00:00 2017-02-19 America/Sao_Paulo +2017-02-20 00:00:00 1487559600 2017-02-20 00:00:00 2017-02-20 America/Sao_Paulo +2017-10-12 00:00:00 1507777200 2017-10-12 00:00:00 2017-10-12 America/Sao_Paulo +2017-10-13 00:00:00 1507863600 2017-10-13 00:00:00 2017-10-13 America/Sao_Paulo +2017-10-14 00:00:00 1507950000 2017-10-14 00:00:00 2017-10-14 America/Sao_Paulo +2017-10-15 00:00:00 1508032800 2017-10-14 23:00:00 2017-10-14 America/Sao_Paulo +2017-10-16 00:00:00 1508119200 2017-10-16 00:00:00 2017-10-16 America/Sao_Paulo +2017-10-17 00:00:00 1508205600 2017-10-17 00:00:00 2017-10-17 America/Sao_Paulo +2017-10-18 00:00:00 1508292000 2017-10-18 00:00:00 2017-10-18 America/Sao_Paulo +2017-10-19 00:00:00 1508378400 2017-10-19 00:00:00 2017-10-19 America/Sao_Paulo diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/input b/go/regtest/cases/dsl-local-date-time-functions/0002/input similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/input rename to go/regtest/cases/dsl-local-date-time-functions/0002/input diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/mlr b/go/regtest/cases/dsl-local-date-time-functions/0002/mlr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0002/mlr rename to go/regtest/cases/dsl-local-date-time-functions/0002/mlr diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/cmd b/go/regtest/cases/dsl-local-date-time-functions/0003/cmd similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/cmd rename to go/regtest/cases/dsl-local-date-time-functions/0003/cmd diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/env b/go/regtest/cases/dsl-local-date-time-functions/0003/env similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/env rename to go/regtest/cases/dsl-local-date-time-functions/0003/env diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/experr b/go/regtest/cases/dsl-local-date-time-functions/0003/experr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/experr rename to go/regtest/cases/dsl-local-date-time-functions/0003/experr diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/expout b/go/regtest/cases/dsl-local-date-time-functions/0003/expout similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/expout rename to go/regtest/cases/dsl-local-date-time-functions/0003/expout diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/input b/go/regtest/cases/dsl-local-date-time-functions/0003/input similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/input rename to go/regtest/cases/dsl-local-date-time-functions/0003/input diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/mlr b/go/regtest/cases/dsl-local-date-time-functions/0003/mlr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0003/mlr rename to go/regtest/cases/dsl-local-date-time-functions/0003/mlr diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/cmd b/go/regtest/cases/dsl-local-date-time-functions/0004/cmd similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/cmd rename to go/regtest/cases/dsl-local-date-time-functions/0004/cmd diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/env b/go/regtest/cases/dsl-local-date-time-functions/0004/env similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/env rename to go/regtest/cases/dsl-local-date-time-functions/0004/env diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/experr b/go/regtest/cases/dsl-local-date-time-functions/0004/experr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/experr rename to go/regtest/cases/dsl-local-date-time-functions/0004/experr diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/expout b/go/regtest/cases/dsl-local-date-time-functions/0004/expout similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/expout rename to go/regtest/cases/dsl-local-date-time-functions/0004/expout diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/input b/go/regtest/cases/dsl-local-date-time-functions/0004/input similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/input rename to go/regtest/cases/dsl-local-date-time-functions/0004/input diff --git a/go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/mlr b/go/regtest/cases/dsl-local-date-time-functions/0004/mlr similarity index 100% rename from go/regtest/cases-pending-windows/dsl-local-date-time-functions/0004/mlr rename to go/regtest/cases/dsl-local-date-time-functions/0004/mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/cmd new file mode 100644 index 000000000..20654eb5c --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/gmt2localtime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/expout new file mode 100644 index 000000000..59da5360d --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-istanbul/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- GMT2LOCALTIME / LOCALTIME2GMT +1970-01-01 02:00:00 +1969-12-31T22:00:00Z diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/cmd new file mode 100644 index 000000000..9f7568195 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/gmt2localtime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/expout new file mode 100644 index 000000000..5a7cdc394 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-sao_paulo/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- GMT2LOCALTIME / LOCALTIME2GMT +1969-12-31 21:00:00 +1970-01-01T03:00:00Z diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/cmd new file mode 100644 index 000000000..ec7b8834c --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/gmt2localtime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/expout new file mode 100644 index 000000000..935978070 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2localtime-utc/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- GMT2LOCALTIME / LOCALTIME2GMT +1970-01-01 00:00:00 +1970-01-01T00:00:00Z diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/cmd new file mode 100644 index 000000000..ec9c2d2b7 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/gmt2sec-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/expout new file mode 100644 index 000000000..69c461a5d --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-istanbul/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- GMT2SEC +0 +0.123456 diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/cmd new file mode 100644 index 000000000..0292bf65a --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/gmt2sec-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/expout new file mode 100644 index 000000000..9514e7c72 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-sao_paulo/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- GMT2SEC +0 +0.123456 diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/cmd new file mode 100644 index 000000000..954f51f62 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/gmt2sec-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/expout new file mode 100644 index 000000000..369cd951f --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/gmt2sec-utc/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- GMT2SEC +0 +0.123456 diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/cmd new file mode 100644 index 000000000..a70914c5e --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/localtime2sec-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/expout new file mode 100644 index 000000000..269dea854 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-istanbul/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- LOCALTIME2SEC +-7200 +(error) diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/cmd new file mode 100644 index 000000000..d6d8a2f48 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/localtime2sec-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/expout new file mode 100644 index 000000000..c2c98bb6c --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-sao_paulo/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- LOCALTIME2SEC +10800 +(error) diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/cmd new file mode 100644 index 000000000..f1c781e0b --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/localtime2sec-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/expout new file mode 100644 index 000000000..cd76d26cd --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/localtime2sec-utc/expout @@ -0,0 +1,5 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- LOCALTIME2SEC +0 +(error) diff --git a/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/cmd b/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/cmd new file mode 100644 index 000000000..f77bd2431 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/cmd @@ -0,0 +1 @@ +mlr --tz this-is-not-a-valid-timezone-name -n put -f regtest/input/sec2localtime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/experr b/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/experr new file mode 100644 index 000000000..66454b669 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/experr @@ -0,0 +1 @@ +mlr: unknown time zone this-is-not-a-valid-timezone-name diff --git a/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/expout b/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/expout new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/should-fail b/go/regtest/cases/dsl-local-date-time-functions/not-a-valid-timezone/should-fail new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/cmd new file mode 100644 index 000000000..18df78fb3 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/sec2gmt-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/expout new file mode 100644 index 000000000..2474a341c --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-istanbul/expout @@ -0,0 +1,8 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- SEC2GMT +1970-01-01T00:00:00Z +1970-01-01T00:00:00Z +1969-12-31T23:59:59Z +1970-01-01T00:00:00.123456Z +1969-12-31T23:59:59.876544Z diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/cmd new file mode 100644 index 000000000..9d30e1231 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/sec2gmt-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/expout new file mode 100644 index 000000000..cc006d4a3 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-sao_paulo/expout @@ -0,0 +1,8 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- SEC2GMT +1970-01-01T00:00:00Z +1970-01-01T00:00:00Z +1969-12-31T23:59:59Z +1970-01-01T00:00:00.123456Z +1969-12-31T23:59:59.876544Z diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/cmd new file mode 100644 index 000000000..90a54df71 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/sec2gmt-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/expout new file mode 100644 index 000000000..31ff563f2 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmt-utc/expout @@ -0,0 +1,8 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- SEC2GMT +1970-01-01T00:00:00Z +1970-01-01T00:00:00Z +1969-12-31T23:59:59Z +1970-01-01T00:00:00.123456Z +1969-12-31T23:59:59.876544Z diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/cmd new file mode 100644 index 000000000..ad428bd90 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/sec2gmtdate-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/expout new file mode 100644 index 000000000..cce07f7f1 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-istanbul/expout @@ -0,0 +1,6 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- SEC2GMTDATE +1970-01-01 +1970-01-01 +1969-12-31 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/cmd new file mode 100644 index 000000000..86c8aa646 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/sec2gmtdate-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/expout new file mode 100644 index 000000000..c317ee311 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-sao_paulo/expout @@ -0,0 +1,6 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- SEC2GMTDATE +1970-01-01 +1970-01-01 +1969-12-31 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/cmd new file mode 100644 index 000000000..c57e6c4dd --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/sec2gmtdate-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/expout new file mode 100644 index 000000000..56db5a7ae --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2gmtdate-utc/expout @@ -0,0 +1,6 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- SEC2GMTDATE +1970-01-01 +1970-01-01 +1969-12-31 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/cmd new file mode 100644 index 000000000..94b4ac0a6 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/sec2localdate-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/expout new file mode 100644 index 000000000..e4b971967 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-istanbul/expout @@ -0,0 +1,6 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- SEC2LOCALDATE +1970-01-01 +1970-01-01 +1970-01-01 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/cmd new file mode 100644 index 000000000..f1bc44d59 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/sec2localdate-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/expout new file mode 100644 index 000000000..d66571b7a --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-sao_paulo/expout @@ -0,0 +1,6 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- SEC2LOCALDATE +1969-12-31 +1969-12-31 +1969-12-31 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/cmd new file mode 100644 index 000000000..81d5a7e77 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/sec2localdate-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/expout new file mode 100644 index 000000000..94bb80024 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localdate-utc/expout @@ -0,0 +1,6 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- SEC2LOCALDATE +1970-01-01 +1970-01-01 +1969-12-31 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/cmd new file mode 100644 index 000000000..aa18143bd --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/sec2localtime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/expout new file mode 100644 index 000000000..bb9e7a9ba --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-istanbul/expout @@ -0,0 +1,8 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- SEC2LOCALTILME +1970-01-01 02:00:00 +1970-01-01 02:00:00 +1970-01-01 01:59:59 +1970-01-01 02:00:00.123456 +1970-01-01 01:59:59.876544 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/cmd new file mode 100644 index 000000000..c1db1eeb7 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/sec2localtime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/expout new file mode 100644 index 000000000..0c1025d98 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-sao_paulo/expout @@ -0,0 +1,8 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- SEC2LOCALTILME +1969-12-31 21:00:00 +1969-12-31 21:00:00 +1969-12-31 20:59:59 +1969-12-31 21:00:00.123456 +1969-12-31 20:59:59.876544 diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/cmd new file mode 100644 index 000000000..18d2712af --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/sec2localtime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/expout new file mode 100644 index 000000000..e9192b077 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/sec2localtime-utc/expout @@ -0,0 +1,8 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- SEC2LOCALTILME +1970-01-01 00:00:00 +1970-01-01 00:00:00 +1969-12-31 23:59:59 +1970-01-01 00:00:00.123456 +1969-12-31 23:59:59.876544 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/cmd new file mode 100644 index 000000000..a3829945b --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/strftime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/expout new file mode 100644 index 000000000..b87bc3d3a --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime-istanbul/expout @@ -0,0 +1,12 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- STRFTIME +1970-01-01T00:00:00Z +1970-01-01 00:00:00 +1970-01-01 00:00:00.000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/cmd new file mode 100644 index 000000000..6e436ab1b --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/strftime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/expout new file mode 100644 index 000000000..addbf579f --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime-sao_paulo/expout @@ -0,0 +1,12 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- STRFTIME +1970-01-01T00:00:00Z +1970-01-01 00:00:00 +1970-01-01 00:00:00.000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/cmd new file mode 100644 index 000000000..8b3a84e7e --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/strftime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/expout new file mode 100644 index 000000000..d47ca354f --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime-utc/expout @@ -0,0 +1,12 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- STRFTIME +1970-01-01T00:00:00Z +1970-01-01 00:00:00 +1970-01-01 00:00:00.000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/cmd new file mode 100644 index 000000000..eb0bc2188 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/strftime_local-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/expout new file mode 100644 index 000000000..b46706738 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-istanbul/expout @@ -0,0 +1,11 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- STRFTIME_LOCAL +1970-01-01 02:00:00 +1970-01-01 02:00:00.000 +1970-01-01 02:00:00 EET +1970-01-01 02:00:00 +0200 +1970-01-01 02:00:00 EET +1970-01-01 02:00:00 +0200 +1970-01-01 02:00:00 EET +1970-01-01 02:00:00 +0200 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/cmd new file mode 100644 index 000000000..a74fc0964 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/strftime_local-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/expout new file mode 100644 index 000000000..b930f1682 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-sao_paulo/expout @@ -0,0 +1,11 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- STRFTIME_LOCAL +1969-12-31 21:00:00 +1969-12-31 21:00:00.000 +1969-12-31 21:00:00 -03 +1969-12-31 21:00:00 -0300 +1969-12-31 21:00:00 -03 +1969-12-31 21:00:00 -0300 +1969-12-31 21:00:00 -03 +1969-12-31 21:00:00 -0300 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/cmd new file mode 100644 index 000000000..575de9f6d --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/strftime_local-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/expout new file mode 100644 index 000000000..25cdf6801 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strftime_local-utc/expout @@ -0,0 +1,11 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- STRFTIME_LOCAL +1970-01-01 00:00:00 +1970-01-01 00:00:00.000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 +1970-01-01 00:00:00 UTC +1970-01-01 00:00:00 +0000 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/cmd new file mode 100644 index 000000000..4c4d010a0 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/strptime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/expout new file mode 100644 index 000000000..0ebc1a488 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-istanbul/expout @@ -0,0 +1,9 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- STRPTIME +0 +0.345 +0.345 +0.345 +14400.345 +-14399.655 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/cmd new file mode 100644 index 000000000..60037166c --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/strptime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/expout new file mode 100644 index 000000000..69d2d2a47 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-sao_paulo/expout @@ -0,0 +1,9 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- STRPTIME +0 +0.345 +0.345 +0.345 +14400.345 +-14399.655 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/cmd new file mode 100644 index 000000000..054c5ea4f --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/strptime-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/expout new file mode 100644 index 000000000..6d37e2a2c --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-utc/expout @@ -0,0 +1,9 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- STRPTIME +0 +0.345 +0.345 +0.345 +14400.345 +-14399.655 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-z/cmd b/go/regtest/cases/dsl-local-date-time-functions/strptime-z/cmd new file mode 100644 index 000000000..6add080d4 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-z/cmd @@ -0,0 +1 @@ +mlr -n put -f ${CASEDIR}/mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-z/experr b/go/regtest/cases/dsl-local-date-time-functions/strptime-z/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-z/expout b/go/regtest/cases/dsl-local-date-time-functions/strptime-z/expout new file mode 100644 index 000000000..319358eb7 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-z/expout @@ -0,0 +1,15 @@ + +TZ UTC +intime 1970-01-01T00:00:00-0400 +parsed 14400 +formatted 1970-01-01T04:00:00+0000 + +TZ America/Sao_Paulo +intime 1970-01-01T00:00:00-0400 +parsed 14400 +formatted 1970-01-01T04:00:00+0000 + +TZ Asia/Istanbul +intime 1970-01-01T00:00:00-0400 +parsed 14400 +formatted 1970-01-01T04:00:00+0000 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime-z/mlr b/go/regtest/cases/dsl-local-date-time-functions/strptime-z/mlr new file mode 100644 index 000000000..1679443ea --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime-z/mlr @@ -0,0 +1,17 @@ +end { + tzs = ["UTC", "America/Sao_Paulo", "Asia/Istanbul"]; + + for (tz in tzs) { + ENV["TZ"] = tz; + # Expect these to not vary with $TZ since we are using %z + intime = "1970-01-01T00:00:00-0400"; + parsed = strptime(intime, "%Y-%m-%dT%H:%M:%S%z"); + formatted = strftime(parsed, "%Y-%m-%dT%H:%M:%S%z"); + + print; + print "TZ ", tz; + print "intime ", intime; + print "parsed ", parsed; + print "formatted", formatted; + } +} diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/cmd b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/cmd new file mode 100644 index 000000000..5eb67bf14 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/cmd @@ -0,0 +1 @@ +mlr --tz Asia/Istanbul -n put -f regtest/input/strptime_local-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/experr b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/expout b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/expout new file mode 100644 index 000000000..d58aa7ee9 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-istanbul/expout @@ -0,0 +1,4 @@ +---------------------------------------------------------------- TIMEZONE +TZ is Asia/Istanbul +---------------------------------------------------------------- STRPTIME_LOCAL +-7200 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/cmd b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/cmd new file mode 100644 index 000000000..468a9f7b4 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/cmd @@ -0,0 +1 @@ +mlr --tz America/Sao_Paulo -n put -f regtest/input/strptime_local-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/experr b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/expout b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/expout new file mode 100644 index 000000000..c634afa58 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-sao_paulo/expout @@ -0,0 +1,4 @@ +---------------------------------------------------------------- TIMEZONE +TZ is America/Sao_Paulo +---------------------------------------------------------------- STRPTIME_LOCAL +10800 diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/cmd b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/cmd new file mode 100644 index 000000000..be305cd25 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/cmd @@ -0,0 +1 @@ +mlr --tz UTC -n put -f regtest/input/strptime_local-tz.mlr diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/experr b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/experr new file mode 100644 index 000000000..e69de29bb diff --git a/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/expout b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/expout new file mode 100644 index 000000000..cb1425796 --- /dev/null +++ b/go/regtest/cases/dsl-local-date-time-functions/strptime_local-utc/expout @@ -0,0 +1,4 @@ +---------------------------------------------------------------- TIMEZONE +TZ is UTC +---------------------------------------------------------------- STRPTIME_LOCAL +0 diff --git a/go/regtest/cases/verb-label/0009/experr b/go/regtest/cases/verb-label/0009/experr index 020420c38..615cfe2bf 100644 --- a/go/regtest/cases/verb-label/0009/experr +++ b/go/regtest/cases/verb-label/0009/experr @@ -1,2 +1 @@ mlr label: labels must be unique; got duplicate "d" -Internal coding error detected at file mlrcli_parse.go line 184 diff --git a/go/regtest/input/gmt2localtime-tz.mlr b/go/regtest/input/gmt2localtime-tz.mlr new file mode 100644 index 000000000..5647c56f1 --- /dev/null +++ b/go/regtest/input/gmt2localtime-tz.mlr @@ -0,0 +1,10 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- GMT2LOCALTIME / LOCALTIME2GMT"; + print gmt2localtime("1970-01-01T00:00:00Z"); + print localtime2gmt("1970-01-01 00:00:00"); + +} diff --git a/go/regtest/input/gmt2sec-tz.mlr b/go/regtest/input/gmt2sec-tz.mlr new file mode 100644 index 000000000..13648e083 --- /dev/null +++ b/go/regtest/input/gmt2sec-tz.mlr @@ -0,0 +1,10 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- GMT2SEC"; + print gmt2sec("1970-01-01T00:00:00Z"); + print gmt2sec("1970-01-01T00:00:00.123456Z"); + +} diff --git a/go/regtest/input/localtime2sec-tz.mlr b/go/regtest/input/localtime2sec-tz.mlr new file mode 100644 index 000000000..87dd9b198 --- /dev/null +++ b/go/regtest/input/localtime2sec-tz.mlr @@ -0,0 +1,10 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- LOCALTIME2SEC"; + print localtime2sec("1970-01-01 00:00:00"); + print localtime2sec("1970-01-01 00:00:00.123456"); + +} diff --git a/go/regtest/input/sec2gmt-tz.mlr b/go/regtest/input/sec2gmt-tz.mlr new file mode 100644 index 000000000..0d3949d9b --- /dev/null +++ b/go/regtest/input/sec2gmt-tz.mlr @@ -0,0 +1,13 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- SEC2GMT"; + print sec2gmt(0); + print sec2gmt(0.123456); + print sec2gmt(-0.123456); + print sec2gmt(0.123456, 6); + print sec2gmt(-0.123456, 6); + +} diff --git a/go/regtest/input/sec2gmtdate-tz.mlr b/go/regtest/input/sec2gmtdate-tz.mlr new file mode 100644 index 000000000..0ad2a4114 --- /dev/null +++ b/go/regtest/input/sec2gmtdate-tz.mlr @@ -0,0 +1,11 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- SEC2GMTDATE"; + print sec2gmtdate(0.0); + print sec2gmtdate(0.123456); + print sec2gmtdate(-0.123456); + +} diff --git a/go/regtest/input/sec2localdate-tz.mlr b/go/regtest/input/sec2localdate-tz.mlr new file mode 100644 index 000000000..96a95f897 --- /dev/null +++ b/go/regtest/input/sec2localdate-tz.mlr @@ -0,0 +1,11 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- SEC2LOCALDATE"; + print sec2localdate(0); + print sec2localdate(0.123456); + print sec2localdate(-0.123456); + +} diff --git a/go/regtest/input/sec2localtime-tz.mlr b/go/regtest/input/sec2localtime-tz.mlr new file mode 100644 index 000000000..e7d309962 --- /dev/null +++ b/go/regtest/input/sec2localtime-tz.mlr @@ -0,0 +1,13 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- SEC2LOCALTILME"; + print sec2localtime(0); + print sec2localtime(0.123456); + print sec2localtime(-0.123456); + print sec2localtime(0.123456, 6); + print sec2localtime(-0.123456, 6); + +} diff --git a/go/regtest/input/strftime-tz.mlr b/go/regtest/input/strftime-tz.mlr new file mode 100644 index 000000000..f789f2fcc --- /dev/null +++ b/go/regtest/input/strftime-tz.mlr @@ -0,0 +1,17 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- STRFTIME"; + print strftime(0.123456, "%Y-%m-%dT%H:%M:%SZ"); + print strftime(0.0, "%Y-%m-%d %H:%M:%S"); + print strftime(0.0, "%Y-%m-%d %H:%M:%3S"); + print strftime(0.0, "%Y-%m-%d %H:%M:%S %Z"); + print strftime(0.0, "%Y-%m-%d %H:%M:%S %z"); + print strftime(0.123456, "%Y-%m-%d %H:%M:%S %Z"); + print strftime(0.123456, "%Y-%m-%d %H:%M:%S %z"); + print strftime(0.0, "%Y-%m-%d %H:%M:%S %Z"); + print strftime(0.0, "%Y-%m-%d %H:%M:%S %z"); + +} diff --git a/go/regtest/input/strftime_local-tz.mlr b/go/regtest/input/strftime_local-tz.mlr new file mode 100644 index 000000000..45917bea2 --- /dev/null +++ b/go/regtest/input/strftime_local-tz.mlr @@ -0,0 +1,17 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- STRFTIME_LOCAL"; + print strftime_local(0.0, "%Y-%m-%d %H:%M:%S"); + print strftime_local(0.0, "%Y-%m-%d %H:%M:%3S"); + + print strftime_local(0.0, "%Y-%m-%d %H:%M:%S %Z"); + print strftime_local(0.0, "%Y-%m-%d %H:%M:%S %z"); + print strftime_local(0.123456, "%Y-%m-%d %H:%M:%S %Z"); + print strftime_local(0.123456, "%Y-%m-%d %H:%M:%S %z"); + print strftime_local(0.0, "%Y-%m-%d %H:%M:%S %Z"); + print strftime_local(0.0, "%Y-%m-%d %H:%M:%S %z"); + +} diff --git a/go/regtest/input/strptime-tz.mlr b/go/regtest/input/strptime-tz.mlr new file mode 100644 index 000000000..bab2a583e --- /dev/null +++ b/go/regtest/input/strptime-tz.mlr @@ -0,0 +1,14 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- STRPTIME"; + print strptime("1970-01-01T00:00:00Z", "%Y-%m-%dT%H:%M:%SZ"); + print strptime("1970-01-01T00:00:00.345Z", "%Y-%m-%dT%H:%M:%SZ"); + print strptime("1970-01-01T00:00:00.345 UTC", "%Y-%m-%dT%H:%M:%S %Z"); + print strptime("1970-01-01T00:00:00.345 EST", "%Y-%m-%dT%H:%M:%S %Z"); + print strptime("1970-01-01T00:00:00.345 -0400", "%Y-%m-%dT%H:%M:%S %z"); + print strptime("1970-01-01T00:00:00.345 +0400", "%Y-%m-%dT%H:%M:%S %z"); + +} diff --git a/go/regtest/input/strptime_local-tz.mlr b/go/regtest/input/strptime_local-tz.mlr new file mode 100644 index 000000000..7b41efa13 --- /dev/null +++ b/go/regtest/input/strptime_local-tz.mlr @@ -0,0 +1,9 @@ +end { + + print "---------------------------------------------------------------- TIMEZONE"; + print "TZ is", ENV["TZ"]; + + print "---------------------------------------------------------------- STRPTIME_LOCAL"; + print strptime_local("1970-01-01 00:00:00", "%Y-%m-%d %H:%M:%S"); + +} diff --git a/go/src/cli/option_parse.go b/go/src/cli/option_parse.go index 48ddb1818..a29d255bb 100644 --- a/go/src/cli/option_parse.go +++ b/go/src/cli/option_parse.go @@ -2503,6 +2503,17 @@ var MiscFlagSection = FlagSection{ }, }, + { + name: "--tz", + arg: "{timezone}", + help: "Specify timezone, overriding `$TZ` environment variable (if any).", + parser: func(args []string, argc int, pargi *int, options *TOptions) { + CheckArgCount(args, *pargi, argc, 2) + os.Setenv("TZ", args[*pargi+1]) + *pargi += 2 + }, + }, + { name: "--nr-progress-mod", arg: "{m}", diff --git a/go/src/climain/mlrcli_parse.go b/go/src/climain/mlrcli_parse.go index 14ea5f961..0b37197a8 100644 --- a/go/src/climain/mlrcli_parse.go +++ b/go/src/climain/mlrcli_parse.go @@ -61,6 +61,9 @@ func ParseCommandLine(args []string) ( } } + // Check now to avoid confusing timezone-library behavior later on + lib.SetTZFromEnv() + cli.FinalizeReaderOptions(&options.ReaderOptions) cli.FinalizeWriterOptions(&options.WriterOptions) diff --git a/go/src/dsl/cst/builtin_function_manager.go b/go/src/dsl/cst/builtin_function_manager.go index fed2b6e4e..8945e0c9e 100644 --- a/go/src/dsl/cst/builtin_function_manager.go +++ b/go/src/dsl/cst/builtin_function_manager.go @@ -395,7 +395,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { { name: "gsub", class: FUNC_CLASS_STRING, - help: `Example: '$name=gsub($name, "old", "new")' (replace all).`, + help: `'$name=gsub($name, "old", "new")' (replace all).`, ternaryFunc: types.MlrvalGsub, }, @@ -409,14 +409,14 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { { name: "regextract", class: FUNC_CLASS_STRING, - help: `Example: '$name=regextract($name, "[A-Z]{3}[0-9]{2}")'`, + help: `'$name=regextract($name, "[A-Z]{3}[0-9]{2}")'`, binaryFunc: types.MlrvalRegextract, }, { name: "regextract_or_else", class: FUNC_CLASS_STRING, - help: `Example: '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")'`, + help: `'$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")'`, ternaryFunc: types.MlrvalRegextractOrElse, }, @@ -451,7 +451,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { { name: "sub", class: FUNC_CLASS_STRING, - help: `Example: '$name=sub($name, "old", "new")' (replace once).`, + help: `'$name=sub($name, "old", "new")' (replace once).`, ternaryFunc: types.MlrvalSub, }, @@ -792,97 +792,140 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { // FUNC_CLASS_TIME { - name: "gmt2sec", - class: FUNC_CLASS_TIME, - help: `Parses GMT timestamp as integer seconds since the epoch.`, + name: "gmt2sec", + class: FUNC_CLASS_TIME, + help: `Parses GMT timestamp as integer seconds since the epoch.`, + examples: []string{ + `gmt2sec("2001-02-03T04:05:06Z") = 981173106`, + }, unaryFunc: types.MlrvalGMT2Sec, }, { - name: "localtime2sec", - class: FUNC_CLASS_TIME, - help: `Parses local timestamp as integer seconds since the epoch. Consults $TZ environment variable.`, + name: "localtime2sec", + class: FUNC_CLASS_TIME, + help: `Parses local timestamp as integer seconds since the epoch. Consults $TZ environment variable.`, + examples: []string{ + `localtime2sec("2001-02-03 04:05:06") = 981165906 with TZ="Asia/Istanbul"`, + }, unaryFunc: types.MlrvalLocalTime2Sec, }, { - name: "sec2gmt", - class: FUNC_CLASS_TIME, - help: `Formats seconds since epoch (integer part) as GMT timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part`, + name: "sec2gmt", + class: FUNC_CLASS_TIME, + help: `Formats seconds since epoch as GMT timestamp. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part.`, + examples: []string{ + `sec2gmt(1234567890) = "2009-02-13T23:31:30Z"`, + `sec2gmt(1234567890.123456) = "2009-02-13T23:31:30Z"`, + `sec2gmt(1234567890.123456, 6) = "2009-02-13T23:31:30.123456Z"`, + }, unaryFunc: types.MlrvalSec2GMTUnary, binaryFunc: types.MlrvalSec2GMTBinary, hasMultipleArities: true, }, { - name: "sec2localtime", - class: FUNC_CLASS_TIME, - help: `Formats seconds since epoch (integer part) as local timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part`, + name: "sec2localtime", + class: FUNC_CLASS_TIME, + help: `Formats seconds since epoch (integer part) as local timestamp. Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part`, + examples: []string{ + `sec2localtime(1234567890) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul"`, + `sec2localtime(1234567890.123456) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul"`, + `sec2localtime(1234567890.123456, 6) = "2009-02-14 01:31:30.123456" with TZ="Asia/Istanbul"`, + }, unaryFunc: types.MlrvalSec2LocalTimeUnary, binaryFunc: types.MlrvalSec2LocalTimeBinary, hasMultipleArities: true, }, { - name: "sec2gmtdate", - class: FUNC_CLASS_TIME, - help: `Formats seconds since epoch (integer part) as GMT timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is.`, + name: "sec2gmtdate", + class: FUNC_CLASS_TIME, + help: `Formats seconds since epoch (integer part) as GMT timestamp with year-month-date. Leaves non-numbers as-is.`, + examples: []string{ + `sec2gmtdate(1440768801.7) = "2015-08-28".`, + }, unaryFunc: types.MlrvalSec2GMTDate, }, { - name: "sec2localdate", - class: FUNC_CLASS_TIME, - help: `Formats seconds since epoch (integer part) as local timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. Consults $TZ environment variable.`, + name: "sec2localdate", + class: FUNC_CLASS_TIME, + help: `Formats seconds since epoch (integer part) as local timestamp with year-month-date. Leaves non-numbers as-is. Consults $TZ environment variable.`, + examples: []string{ + `sec2localdate(1440768801.7) = "2015-08-28" with TZ="Asia/Istanbul"`, + }, unaryFunc: types.MlrvalSec2LocalDate, }, { - name: "systime", - class: FUNC_CLASS_TIME, - help: "help string will go here", - zaryFunc: types.MlrvalSystime, + name: "localtime2gmt", + class: FUNC_CLASS_TIME, + help: `Convert from a local-time string to a GMT-time string, consulting $TZ`, + examples: []string{ + `localtime2gmt("2000-01-01 00:00:00") = "1999-12-31T22:00:00Z" with TZ="Asia/Istanbul"`, + }, + unaryFunc: types.MlrvalLocalTime2GMT, }, { - name: "systimeint", - class: FUNC_CLASS_TIME, - help: "help string will go here", - zaryFunc: types.MlrvalSystimeInt, + name: "gmt2localtime", + class: FUNC_CLASS_TIME, + help: `Convert from a GMT-time string to a local-time string, consulting $TZ`, + examples: []string{ + `gmt2localtime("1999-12-31T22:00:00Z") = "2000-01-01 00:00:00" with TZ="Asia/Istanbul"`, + }, + unaryFunc: types.MlrvalGMT2LocalTime, }, { - name: "uptime", - class: FUNC_CLASS_TIME, - help: "help string will go here", - zaryFunc: types.MlrvalUptime, - }, - - { - name: "strftime", - class: FUNC_CLASS_TIME, - help: `Formats seconds since the epoch as timestamp, e.g. strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z", and strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z". Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local.`, + name: "strftime", + class: FUNC_CLASS_TIME, + help: `Formats seconds since the epoch as timestamp. Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local.`, + examples: []string{ + `strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z"`, + `strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z"`, + }, binaryFunc: types.MlrvalStrftime, }, { - name: "strptime", - class: FUNC_CLASS_TIME, - help: `strptime: Parses timestamp as floating-point seconds since the epoch, e.g. strptime("2015-08-28T13:33:21Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000, and strptime("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000. See also strptime_local.`, + name: "strptime", + class: FUNC_CLASS_TIME, + help: `strptime: Parses timestamp as floating-point seconds since the epoch. See also strptime_local.`, + examples: []string{ + `strptime("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000`, + `strptime("2015-08-28T13:33:21.345Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000`, + `strptime("1970-01-01 00:00:00 -0400", "%Y-%m-%d %H:%M:%S %z") = 14400`, + `strptime("1970-01-01 00:00:00 EET", "%Y-%m-%d %H:%M:%S %Z") = -7200`, + }, + binaryFunc: types.MlrvalStrptime, }, { - name: "strftime_local", - class: FUNC_CLASS_TIME, - help: `Like strftime but consults the $TZ environment variable to get local time zone.`, + name: "strftime_local", + class: FUNC_CLASS_TIME, + help: `Like strftime but consults the $TZ environment variable to get local time zone.`, + examples: []string{ + `strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%S %z") = "2015-08-28 16:33:21 +0300" with TZ="Asia/Istanbul"`, + `strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%3S %z") = "2015-08-28 16:33:21.700 +0300" with TZ="Asia/Istanbul"`, + }, binaryFunc: types.MlrvalStrftimeLocal, }, { - name: "strptime_local", - class: FUNC_CLASS_TIME, - help: `Like stpftime but consults the $TZ environment variable to get local time zone.`, + name: "strptime_local", + class: FUNC_CLASS_TIME, + help: `Like stpftime but consults the $TZ environment variable to get local time zone.`, + examples: []string{ + `strptime_local("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440758001 with TZ="Asia/Istanbul"`, + `strptime_local("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440758001.345 with TZ="Asia/Istanbul"`, + `strptime_local("2015-08-28 13:33:21", "%Y-%m-%d %H:%M:%S") = 1440758001 with TZ="Asia/Istanbul"`, + // TODO: fix parse error on decimal part + //`strptime_local("2015-08-28 13:33:21.345","%Y-%m-%d %H:%M:%S") = 1440758001.345`, + }, binaryFunc: types.MlrvalStrptimeLocal, }, @@ -942,6 +985,27 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { unaryFunc: types.MlrvalSec2HMS, }, + { + name: "systime", + class: FUNC_CLASS_TIME, + help: "help string will go here", + zaryFunc: types.MlrvalSystime, + }, + + { + name: "systimeint", + class: FUNC_CLASS_TIME, + help: "help string will go here", + zaryFunc: types.MlrvalSystimeInt, + }, + + { + name: "uptime", + class: FUNC_CLASS_TIME, + help: "help string will go here", + zaryFunc: types.MlrvalUptime, + }, + // ---------------------------------------------------------------- // FUNC_CLASS_TYPING @@ -1261,8 +1325,8 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Makes string from map/array keys.`, examples: []string{ - `Example: joink({"a":3,"b":4,"c":5}, ",") = "a,b,c".`, - `Example: joink([1,2,3], ",") = "1,2,3".`, + `joink({"a":3,"b":4,"c":5}, ",") = "a,b,c".`, + `joink([1,2,3], ",") = "1,2,3".`, }, binaryFunc: types.MlrvalJoinK, }, @@ -1279,8 +1343,8 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Makes string from map/array key-value pairs.`, examples: []string{ - `Example: joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5"`, - `Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5"`, + `joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5"`, + `joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5"`, }, ternaryFunc: types.MlrvalJoinKV, }, @@ -1290,7 +1354,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Splits string into array with type inference.`, examples: []string{ - `Example: splita("3,4,5", ",") = [3,4,5]`, + `splita("3,4,5", ",") = [3,4,5]`, }, binaryFunc: types.MlrvalSplitA, }, @@ -1300,7 +1364,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Splits string into array without type inference.`, examples: []string{ - `Example: splita("3,4,5", ",") = ["3","4","5"]`, + `splita("3,4,5", ",") = ["3","4","5"]`, }, binaryFunc: types.MlrvalSplitAX, }, @@ -1310,7 +1374,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Splits string by separators into map with type inference.`, examples: []string{ - `Example: splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5}`, + `splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5}`, }, ternaryFunc: types.MlrvalSplitKV, }, @@ -1320,7 +1384,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Splits string by separators into map without type inference (keys and values are strings).`, examples: []string{ - `Example: splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"}`, + `splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"}`, }, ternaryFunc: types.MlrvalSplitKVX, }, @@ -1330,7 +1394,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Splits string by separator into integer-indexed map with type inference.`, examples: []string{ - `Example: splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"}`, + `splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"}`, }, binaryFunc: types.MlrvalSplitNV, }, @@ -1340,7 +1404,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_CONVERSION, help: `Splits string by separator into integer-indexed map without type inference (values are strings).`, examples: []string{ - `Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"}`, + `splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"}`, }, binaryFunc: types.MlrvalSplitNVX, }, @@ -1382,8 +1446,8 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_COLLECTIONS, help: `Flattens multi-level maps to single-level ones. Useful for nested JSON-like structures for non-JSON file formats like CSV.`, examples: []string{ - `Example: flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}.`, - `Example: flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}.`, + `flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}.`, + `flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}.`, `Two-argument version: flatten($*, ".") is the same as flatten("", ".", $*).`, }, binaryFunc: types.MlrvalFlattenBinary, @@ -1476,7 +1540,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { class: FUNC_CLASS_COLLECTIONS, help: `Reverses flatten. Useful for nested JSON-like structures for non-JSON file formats like CSV. See also arrayify.`, examples: []string{ - `Example: unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}.`, + `unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}.`, }, binaryFunc: types.MlrvalUnflatten, }, @@ -1783,6 +1847,12 @@ func (manager *BuiltinFunctionManager) showSingleUsage( describeNargs(builtinFunctionInfo), builtinFunctionInfo.help, ) + if len(builtinFunctionInfo.examples) == 1 { + fmt.Println("Example:") + } + if len(builtinFunctionInfo.examples) > 1 { + fmt.Println("Examples:") + } for _, example := range builtinFunctionInfo.examples { fmt.Println(example) } diff --git a/go/src/dsl/cst/lvalues.go b/go/src/dsl/cst/lvalues.go index ca73dfd43..82d4fe6cc 100644 --- a/go/src/dsl/cst/lvalues.go +++ b/go/src/dsl/cst/lvalues.go @@ -1104,7 +1104,12 @@ func (node *EnvironmentVariableLvalueNode) Assign( ) } - os.Setenv(name.String(), rvalue.String()) + sname := name.String() + svalue := rvalue.String() + os.Setenv(sname, svalue) + if sname == "TZ" { + lib.SetTZFromEnv() // affects the time library; notify it + } return nil } diff --git a/go/src/lib/time.go b/go/src/lib/time.go index 2721561fa..a5af7b34a 100644 --- a/go/src/lib/time.go +++ b/go/src/lib/time.go @@ -3,9 +3,27 @@ package lib import ( "fmt" "math" + "os" "time" ) +// SetTZFromEnv applies the $TZ environment variable. This has three reasons: +// (1) On Windows (as of 2021-10-20), this is necessary to get $TZ into use. +// (2) On Linux/Mac, as of this writing it is not necessary for initial value +// of TZ at startup. However, an explicit check is helpful since if someone +// does 'export TZ=Something/Invalid', then runs Miller, and invalid TZ is +// simply *ignored* -- we want to surface that error to the user. (3) On any +// platform this is necessary for *changing* TZ mid-process: e.g. if a DSL +// statement does 'ENV["TZ"] = Asia/Istanbul'. +func SetTZFromEnv() { + location, err := time.LoadLocation(os.Getenv("TZ")) + if err != nil { + fmt.Fprintf(os.Stderr, "mlr: %v\n", err) + os.Exit(1) + } + time.Local = location +} + func Sec2GMT(epochSeconds float64, numDecimalPlaces int) string { return sec2GMTOrLocalTime(epochSeconds, numDecimalPlaces, false) } @@ -20,9 +38,17 @@ func sec2GMTOrLocalTime(epochSeconds float64, numDecimalPlaces int, doLocal bool intPart := int64(epochSeconds) fractionalPart := epochSeconds - float64(intPart) + if fractionalPart < 0 { + intPart -= 1 + fractionalPart += 1.0 + } decimalPart := int64(fractionalPart * math.Pow(10.0, float64(numDecimalPlaces))) + t := time.Unix(intPart, 0) if doLocal { + // Note: the Go time package doesn't do Getenv("TZ") on every call. + // Rather, it stashes the first call. This means we can't change $TZ + // mid-process for testing purposes. t = t.Local() } else { t = t.UTC() @@ -36,13 +62,25 @@ func sec2GMTOrLocalTime(epochSeconds float64, numDecimalPlaces int, doLocal bool ss := t.Second() if numDecimalPlaces == 0 { - return fmt.Sprintf( - "%04d-%02d-%02dT%02d:%02d:%02dZ", - YYYY, MM, DD, hh, mm, ss) + if doLocal { + return fmt.Sprintf( + "%04d-%02d-%02d %02d:%02d:%02d", + YYYY, MM, DD, hh, mm, ss) + } else { + return fmt.Sprintf( + "%04d-%02d-%02dT%02d:%02d:%02dZ", + YYYY, MM, DD, hh, mm, ss) + } } else { - return fmt.Sprintf( - "%04d-%02d-%02dT%02d:%02d:%02d.%0*dZ", - YYYY, MM, DD, hh, mm, ss, numDecimalPlaces, decimalPart) + if doLocal { + return fmt.Sprintf( + "%04d-%02d-%02d %02d:%02d:%02d.%0*d", + YYYY, MM, DD, hh, mm, ss, numDecimalPlaces, decimalPart) + } else { + return fmt.Sprintf( + "%04d-%02d-%02dT%02d:%02d:%02d.%0*dZ", + YYYY, MM, DD, hh, mm, ss, numDecimalPlaces, decimalPart) + } } } diff --git a/go/src/transformers/label.go b/go/src/transformers/label.go index ee25bf8ae..7c62161c3 100644 --- a/go/src/transformers/label.go +++ b/go/src/transformers/label.go @@ -78,7 +78,8 @@ func transformerLabelParseCLI( ) if err != nil { fmt.Fprint(os.Stderr, err) - return nil + os.Exit(1) + // TODO: return nil to caller and have it exit, maybe } *pargi = argi diff --git a/go/src/types/mlrval_functions_time.go b/go/src/types/mlrval_functions_time.go index a157a602f..a5d9006fe 100644 --- a/go/src/types/mlrval_functions_time.go +++ b/go/src/types/mlrval_functions_time.go @@ -101,6 +101,22 @@ func MlrvalSec2LocalDate(input1 *Mlrval) *Mlrval { } } +// TODO: unary vs binary ... +func MlrvalLocalTime2GMT(input1 *Mlrval) *Mlrval { + if !input1.IsString() { + return MLRVAL_ERROR + } + return MlrvalSec2GMTUnary(MlrvalLocalTime2Sec(input1)) +} + +// TODO: unary vs binary ... +func MlrvalGMT2LocalTime(input1 *Mlrval) *Mlrval { + if !input1.IsString() { + return MLRVAL_ERROR + } + return MlrvalSec2LocalTimeUnary(MlrvalGMT2Sec(input1)) +} + // ================================================================ // Argument 1 is int/float seconds since the epoch. // Argument 2 is format string like "%Y-%m-%d %H:%M:%S". @@ -247,7 +263,6 @@ func MlrvalStrptimeLocal(input1, input2 *Mlrval) *Mlrval { t, err := strptime.ParseTZ(timeString, formatString) if err != nil { - fmt.Printf("err %#v\n", err) return MLRVAL_ERROR } diff --git a/go/todo.txt b/go/todo.txt index 0af1e09a3..a89404134 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -18,11 +18,18 @@ TOP OF LIST: * regtest pendings o webdocs re /..../i regex options @ CLIP for windows -* doc6 +* doc6 * check issues * meta: nf,nr,keys? +* authoritative regex docs accompanied by thorough UT + o expand existing regex webdoc +* authoritative time/localtime/tz docs accompanied by thorough UT + o needs separate webdoc + +* CASEDIR cmd -> mlr via env not oosvar + * punchdown list: o $cpw - 3 regex-at-CLI cases -- repro @ akns @@ -31,12 +38,14 @@ TOP OF LIST: ! fmtnum + - merge-field voids + + - json comments + - mapexcept ... - xtab crlf & non-std irs generally ... - pprint ofs -- ? - xtab ors -- ? - - merge-field voids - - json comments - crlf ... o TODO in *.go & *.mi @@ -50,14 +59,59 @@ d pre-release: ---------------------------------------------------------------- LOCALTIME -* more olh about no-T-no-Z format for localtime +! make optional tz args ! + -> separate PR + sec2localtime 2nd + sec2localdate 3rd ... w/ int 0 @ 2nd ... :( + localtime2sec 2nd + strptime_local 3rd + strftime_local 3rd + gmt2localtime 2nd + localtime2gmt 2nd -* windows debug +* .6S bugfix -- separate PR -- ? -* https://github.com/johnkerl/miller/issues/331 - https://github.com/johnkerl/miller/issues/332 - https://github.com/johnkerl/miller/issues/359 - https://github.com/johnkerl/miller/issues/477 +* new webdoc separate PR + - incl https://github.com/johnkerl/miller/issues/331 + +* ENV["TZ"] update: + o --tz is a setenv & is treated the same. also ENV["TZ"] + o no explicit tz arg @ dsl functions, sorry ... + o now maybe simplify the RTs ... + o at very least, at a multi-tz case + o sec2gmt sec2localtime + sec2gmtdate sec2localdate + strftime strftime_local + o gmt2sec localtime2sec + strptime strptime_local + o gmt2localtime localtime2gmt + o note in new webdoc + mlr> sec2localtime(0) + "1969-12-31 19:00:00" + mlr> ENV["TZ"]="" + mlr> sec2localtime(0) + "1970-01-01 00:00:00" + mlr> ENV["TZ"]="GMT" + mlr> sec2localtime(0) + "1970-01-01 00:00:00" + mlr> ENV["TZ"]="Asia/Istanbul" + mlr> sec2localtime(0) + "1970-01-01 02:00:00" + mlr> ENV["TZ"]="America/Sao_Paulo" + mlr> sec2localtime(0) + "1969-12-31 21:00:00" + o ref: + https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html + http://www.iana.org/time-zones + https://en.wikipedia.org/wiki/Tz_database + https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + +* https://github.com/johnkerl/miller/issues/332 + o localtime2gmt and gmt2localtime + --tz + k maybe health-check with `location, err := time.LoadLocation("America/Los_Angeles")` -- ? + ? make this this applies to all datetimes that don't include a time zone + ? also make sure that, absent this, all zoneless datatimes are interpreted in that timezone ---------------------------------------------------------------- 398 @@ -143,6 +197,8 @@ mlr regtest regtest/cases-pending-go-port/verb-label/0010 BLOCKERS +? BIFs as FCFs? + * regtest: o convert regtest/cases-pending-windows o convert regtest/cases-pending-go-port diff --git a/man6/manpage.txt b/man6/manpage.txt index 8a71693f9..cd40881a1 100644 --- a/man6/manpage.txt +++ b/man6/manpage.txt @@ -171,20 +171,21 @@ FUNCTION LIST asserting_present asserting_string atan atan2 atanh bitcount boolean capitalize cbrt ceil clean_whitespace collapse_whitespace cos cosh depth dhms2fsec dhms2sec erf erfc every exp expm1 flatten float floor fmtnum fold - fsec2dhms fsec2hms get_keys get_values gmt2sec gsub haskey hexfmt hms2fsec - hms2sec hostname int invqnorm is_absent is_array is_bool is_boolean is_empty - is_empty_map is_error is_float is_int is_map is_nonempty_map is_not_array - is_not_empty is_not_map is_not_null is_null is_numeric is_present is_string - joink joinkv joinv json_parse json_stringify leafcount length localtime2sec - log log10 log1p logifit lstrip madd mapdiff mapexcept mapselect mapsum max md5 - mexp min mmul msub os pow qnorm reduce regextract regextract_or_else round - roundm rstrip sec2dhms sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime - select sgn sha1 sha256 sha512 sin sinh sort splita splitax splitkv splitkvx - splitnv splitnvx sqrt ssub strftime strftime_local string strip strlen - strptime strptime_local sub substr substr0 substr1 system systime systimeint - tan tanh tolower toupper truncate typeof unflatten uptime urand urand32 - urandint urandrange version ! != !=~ % & && * ** + - . .* .+ .- ./ / // < << - <= <=> == =~ > >= >> >>> ?: ?? ??? ^ ^^ | || ~ + fsec2dhms fsec2hms get_keys get_values gmt2localtime gmt2sec gsub haskey + hexfmt hms2fsec hms2sec hostname int invqnorm is_absent is_array is_bool + is_boolean is_empty is_empty_map is_error is_float is_int is_map + is_nonempty_map is_not_array is_not_empty is_not_map is_not_null is_null + is_numeric is_present is_string joink joinkv joinv json_parse json_stringify + leafcount length localtime2gmt localtime2sec log log10 log1p logifit lstrip + madd mapdiff mapexcept mapselect mapsum max md5 mexp min mmul msub os pow + qnorm reduce regextract regextract_or_else round roundm rstrip sec2dhms + sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime select sgn sha1 sha256 + sha512 sin sinh sort splita splitax splitkv splitkvx splitnv splitnvx sqrt + ssub strftime strftime_local string strip strlen strptime strptime_local sub + substr substr0 substr1 system systime systimeint tan tanh tolower toupper + truncate typeof unflatten uptime urand urand32 urandint urandrange version ! + != !=~ % & && * ** + - . .* .+ .- ./ / // < << <= <=> == =~ > >= >> >>> ?: ?? + ??? ^ ^^ | || ~ COMMENTS-IN-DATA FLAGS Miller lets you put comments in your data, such as @@ -449,6 +450,8 @@ MISCELLANEOUS FLAGS the `fmtnum` function and the `format-values` verb. --seed {n} with `n` of the form `12345678` or `0xcafefeed`. For `put`/`filter` `urand`, `urandint`, and `urand32`. + --tz {timezone} Specify timezone, overriding `$TZ` environment + variable (if any). -I Process files in-place. For each file name on the command line, output is written to a temp file in the same directory, which is then renamed over the @@ -1865,6 +1868,7 @@ FUNCTIONS FOR FILTER/PUT any (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for any array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: any([10,20,30], func(e) {return $index == e}) Map example: any({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) @@ -1873,6 +1877,7 @@ FUNCTIONS FOR FILTER/PUT apply (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, applies the function to each element of the array/map. For arrays, the function should take one argument, for array element; it should return a new element. For maps, it should take two arguments, for map-element key and value; it should return a new key-value pair (i.e. a single-entry map). + Examples: Array example: apply([1,2,3,4,5], func(e) {return e ** 3}) returns [1, 8, 27, 64, 125]. Map example: apply({"a":1, "b":3, "c":5}, func(k,v) {return {toupper(k): v ** 2}}) returns {"A": 1, "B":9, "C": 25}", @@ -1996,6 +2001,7 @@ FUNCTIONS FOR FILTER/PUT every (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for every array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: every(["a", "b", "c"], func(e) {return $[e] >= 0}) Map example: every({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) @@ -2007,8 +2013,9 @@ FUNCTIONS FOR FILTER/PUT flatten (class=collections #args=3) Flattens multi-level maps to single-level ones. Useful for nested JSON-like structures for non-JSON file formats like CSV. - Example: flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. - Example: flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. + Examples: + flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. + flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. Two-argument version: flatten($*, ".") is the same as flatten("", ".", $*). float @@ -2022,6 +2029,7 @@ FUNCTIONS FOR FILTER/PUT fold (class=higher-order-functions #args=3) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is taken from the third argument. + Examples: Array example: fold([1,2,3,4,5], func(acc,e) {return acc + e**3}, 10000) returns 10225. Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": accv+ev**2}}, {"sum":10000}) returns 10035. @@ -2037,11 +2045,18 @@ FUNCTIONS FOR FILTER/PUT get_values (class=collections #args=1) Returns array of keys of map or array -- in the latter case, returns a copy of the array + gmt2localtime + (class=time #args=1) Convert from a GMT-time string to a local-time string, consulting $TZ + Example: + gmt2localtime("1999-12-31T22:00:00Z") = "2000-01-01 00:00:00" with TZ="Asia/Istanbul" + gmt2sec (class=time #args=1) Parses GMT timestamp as integer seconds since the epoch. + Example: + gmt2sec("2001-02-03T04:05:06Z") = 981173106 gsub - (class=string #args=3) Example: '$name=gsub($name, "old", "new")' (replace all). + (class=string #args=3) '$name=gsub($name, "old", "new")' (replace all). haskey (class=collections #args=2) True/false if map has/hasn't key, e.g. 'haskey($*, "a")' or 'haskey(mymap, mykey)', or true/false if array index is in bounds / out of bounds. Error if 1st argument is not a map or array. Note -n..-1 alias to 1..n in Miller arrays. @@ -2123,13 +2138,15 @@ FUNCTIONS FOR FILTER/PUT joink (class=conversion #args=2) Makes string from map/array keys. - Example: joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". - Example: joink([1,2,3], ",") = "1,2,3". + Examples: + joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". + joink([1,2,3], ",") = "1,2,3". joinkv (class=conversion #args=3) Makes string from map/array key-value pairs. - Example: joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" - Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" + Examples: + joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" + joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" joinv (class=conversion #args=2) Makes string from map/array values. joinv([3,4,5], ",") = "3,4,5" joinv({"a":3,"b":4,"c":5}, ",") = "3,4,5" @@ -2146,8 +2163,15 @@ FUNCTIONS FOR FILTER/PUT length (class=collections #args=1) Counts number of top-level entries in array/map. Scalars have length 1. + localtime2gmt + (class=time #args=1) Convert from a local-time string to a GMT-time string, consulting $TZ + Example: + localtime2gmt("2000-01-01 00:00:00") = "1999-12-31T22:00:00Z" with TZ="Asia/Istanbul" + localtime2sec (class=time #args=1) Parses local timestamp as integer seconds since the epoch. Consults $TZ environment variable. + Example: + localtime2sec("2001-02-03 04:05:06") = 981165906 with TZ="Asia/Istanbul" log (class=math #args=1) Natural (base-e) logarithm. @@ -2208,14 +2232,15 @@ FUNCTIONS FOR FILTER/PUT reduce (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element, and return the accumulated element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is the first element for arrays, or the first element's key-value pair for maps. + Examples: Array example: reduce([1,2,3,4,5], func(acc,e) {return acc + e**3}) returns 225. Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_of_squares": accv + ev**2}}) returns {"sum_of_squares": 35}. regextract - (class=string #args=2) Example: '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' + (class=string #args=2) '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' regextract_or_else - (class=string #args=3) Example: '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' + (class=string #args=3) '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' round (class=math #args=1) Round to nearest integer. @@ -2230,22 +2255,35 @@ FUNCTIONS FOR FILTER/PUT (class=time #args=1) Formats integer seconds as in sec2dhms(500000) = "5d18h53m20s" sec2gmt - (class=time #args=1,2) Formats seconds since epoch (integer part) as GMT timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch as GMT timestamp. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part. + Examples: + sec2gmt(1234567890) = "2009-02-13T23:31:30Z" + sec2gmt(1234567890.123456) = "2009-02-13T23:31:30Z" + sec2gmt(1234567890.123456, 6) = "2009-02-13T23:31:30.123456Z" sec2gmtdate - (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. + (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date. Leaves non-numbers as-is. + Example: + sec2gmtdate(1440768801.7) = "2015-08-28". sec2hms (class=time #args=1) Formats integer seconds as in sec2hms(5000) = "01:23:20" sec2localdate - (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. Consults $TZ environment variable. + (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date. Leaves non-numbers as-is. Consults $TZ environment variable. + Example: + sec2localdate(1440768801.7) = "2015-08-28" with TZ="Asia/Istanbul" sec2localtime - (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp. Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + Examples: + sec2localtime(1234567890) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" + sec2localtime(1234567890.123456) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" + sec2localtime(1234567890.123456, 6) = "2009-02-14 01:31:30.123456" with TZ="Asia/Istanbul" select (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, includes each input element in the output if the function returns true. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. + Examples: Array example: select([1,2,3,4,5], func(e) {return e >= 3}) returns [3, 4, 5]. Map example: select({"a":1, "b":3, "c":5}, func(k,v) {return v >= 3}) returns {"b":3, "c": 5}. @@ -2269,32 +2307,39 @@ FUNCTIONS FOR FILTER/PUT sort (class=higher-order-functions #args=1-2) Given a map or array as first argument and string flags or function as optional second argument, returns a sorted copy of the input. With one argument, sorts array elements naturally, and maps naturally by map keys. If the second argument is a string, it can contain any of "f" for lexical (default "n" for natural/numeric), "), "c" for case-folded lexical, and "r" for reversed/descending sort. If the second argument is a function, then for arrays it should take two arguments a and b, returning < 0, 0, or > 0 as a < b, a == b, or a > b respectively; for maps the function should take four arguments ak, av, bk, and bv, again returning < 0, 0, or > 0, using a and b's keys and values. + Examples: Array example: sort([5,2,3,1,4], func(a,b) {return b <=> a}) returns [5,4,3,2,1]. Map example: sort({"c":2,"a":3,"b":1}, func(ak,av,bk,bv) {return bv <=> av}) returns {"a":3,"c":2,"b":1}. splita (class=conversion #args=2) Splits string into array with type inference. - Example: splita("3,4,5", ",") = [3,4,5] + Example: + splita("3,4,5", ",") = [3,4,5] splitax (class=conversion #args=2) Splits string into array without type inference. - Example: splita("3,4,5", ",") = ["3","4","5"] + Example: + splita("3,4,5", ",") = ["3","4","5"] splitkv (class=conversion #args=3) Splits string by separators into map with type inference. - Example: splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} + Example: + splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} splitkvx (class=conversion #args=3) Splits string by separators into map without type inference (keys and values are strings). - Example: splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} + Example: + splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} splitnv (class=conversion #args=2) Splits string by separator into integer-indexed map with type inference. - Example: splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} + Example: + splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} splitnvx (class=conversion #args=2) Splits string by separator into integer-indexed map without type inference (values are strings). - Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} + Example: + splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} sqrt (class=math #args=1) Square root. @@ -2303,10 +2348,16 @@ FUNCTIONS FOR FILTER/PUT (class=string #args=3) Like sub but does no regexing. No characters are special. strftime - (class=time #args=2) Formats seconds since the epoch as timestamp, e.g. strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z", and strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z". Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. + (class=time #args=2) Formats seconds since the epoch as timestamp. Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. + Examples: + strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z" + strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z" strftime_local (class=time #args=2) Like strftime but consults the $TZ environment variable to get local time zone. + Examples: + strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%S %z") = "2015-08-28 16:33:21 +0300" with TZ="Asia/Istanbul" + strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%3S %z") = "2015-08-28 16:33:21.700 +0300" with TZ="Asia/Istanbul" string (class=conversion #args=1) Convert int/float/bool/string/array/map to string. @@ -2318,13 +2369,22 @@ FUNCTIONS FOR FILTER/PUT (class=string #args=1) String length. strptime - (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch, e.g. strptime("2015-08-28T13:33:21Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000, and strptime("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000. See also strptime_local. + (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch. See also strptime_local. + Examples: + strptime("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000 + strptime("2015-08-28T13:33:21.345Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000 + strptime("1970-01-01 00:00:00 -0400", "%Y-%m-%d %H:%M:%S %z") = 14400 + strptime("1970-01-01 00:00:00 EET", "%Y-%m-%d %H:%M:%S %Z") = -7200 strptime_local (class=time #args=2) Like stpftime but consults the $TZ environment variable to get local time zone. + Examples: + strptime_local("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440758001 with TZ="Asia/Istanbul" + strptime_local("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440758001.345 with TZ="Asia/Istanbul" + strptime_local("2015-08-28 13:33:21", "%Y-%m-%d %H:%M:%S") = 1440758001 with TZ="Asia/Istanbul" sub - (class=string #args=3) Example: '$name=sub($name, "old", "new")' (replace once). + (class=string #args=3) '$name=sub($name, "old", "new")' (replace once). substr (class=string #args=3) substr is an alias for substr0. See also substr1. Miller is generally 1-up with all array and string indices, but, this is a backward-compatibility issue with Miller 5 and below. Arrays are new in Miller 6; the substr function is older. @@ -2364,13 +2424,15 @@ FUNCTIONS FOR FILTER/PUT unflatten (class=collections #args=2) Reverses flatten. Useful for nested JSON-like structures for non-JSON file formats like CSV. See also arrayify. - Example: unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. + Example: + unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. uptime (class=time #args=0) help string will go here urand (class=math #args=0) Floating-point numbers uniformly distributed on the unit interval. + Example: Int-valued example: '$n=floor(20+urand()*11)'. urand32 @@ -2865,4 +2927,4 @@ SEE ALSO - 2021-10-17 MILLER(1) + 2021-10-21 MILLER(1) diff --git a/man6/mlr6.1 b/man6/mlr6.1 index 66eea122a..6160afce1 100644 --- a/man6/mlr6.1 +++ b/man6/mlr6.1 @@ -2,12 +2,12 @@ .\" Title: mlr .\" Author: [see the "AUTHOR" section] .\" Generator: ./mkman.rb -.\" Date: 2021-10-17 +.\" Date: 2021-10-21 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "MILLER" "1" "2021-10-17" "\ \&" "\ \&" +.TH "MILLER" "1" "2021-10-21" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Portability definitions .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -218,20 +218,21 @@ asserting_not_map asserting_not_null asserting_null asserting_numeric asserting_present asserting_string atan atan2 atanh bitcount boolean capitalize cbrt ceil clean_whitespace collapse_whitespace cos cosh depth dhms2fsec dhms2sec erf erfc every exp expm1 flatten float floor fmtnum fold -fsec2dhms fsec2hms get_keys get_values gmt2sec gsub haskey hexfmt hms2fsec -hms2sec hostname int invqnorm is_absent is_array is_bool is_boolean is_empty -is_empty_map is_error is_float is_int is_map is_nonempty_map is_not_array -is_not_empty is_not_map is_not_null is_null is_numeric is_present is_string -joink joinkv joinv json_parse json_stringify leafcount length localtime2sec -log log10 log1p logifit lstrip madd mapdiff mapexcept mapselect mapsum max md5 -mexp min mmul msub os pow qnorm reduce regextract regextract_or_else round -roundm rstrip sec2dhms sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime -select sgn sha1 sha256 sha512 sin sinh sort splita splitax splitkv splitkvx -splitnv splitnvx sqrt ssub strftime strftime_local string strip strlen -strptime strptime_local sub substr substr0 substr1 system systime systimeint -tan tanh tolower toupper truncate typeof unflatten uptime urand urand32 -urandint urandrange version ! != !=~ % & && * ** + - . .* .+ .- ./ / // < << -<= <=> == =~ > >= >> >>> ?: ?? ??? ^ ^^ | || ~ +fsec2dhms fsec2hms get_keys get_values gmt2localtime gmt2sec gsub haskey +hexfmt hms2fsec hms2sec hostname int invqnorm is_absent is_array is_bool +is_boolean is_empty is_empty_map is_error is_float is_int is_map +is_nonempty_map is_not_array is_not_empty is_not_map is_not_null is_null +is_numeric is_present is_string joink joinkv joinv json_parse json_stringify +leafcount length localtime2gmt localtime2sec log log10 log1p logifit lstrip +madd mapdiff mapexcept mapselect mapsum max md5 mexp min mmul msub os pow +qnorm reduce regextract regextract_or_else round roundm rstrip sec2dhms +sec2gmt sec2gmtdate sec2hms sec2localdate sec2localtime select sgn sha1 sha256 +sha512 sin sinh sort splita splitax splitkv splitkvx splitnv splitnvx sqrt +ssub strftime strftime_local string strip strlen strptime strptime_local sub +substr substr0 substr1 system systime systimeint tan tanh tolower toupper +truncate typeof unflatten uptime urand urand32 urandint urandrange version ! +!= !=~ % & && * ** + - . .* .+ .- ./ / // < << <= <=> == =~ > >= >> >>> ?: ?? +??? ^ ^^ | || ~ .fi .if n \{\ .RE @@ -568,6 +569,8 @@ These are flags which don't fit into any other category. the `fmtnum` function and the `format-values` verb. --seed {n} with `n` of the form `12345678` or `0xcafefeed`. For `put`/`filter` `urand`, `urandint`, and `urand32`. +--tz {timezone} Specify timezone, overriding `$TZ` environment + variable (if any). -I Process files in-place. For each file name on the command line, output is written to a temp file in the same directory, which is then renamed over the @@ -2408,6 +2411,7 @@ being 'b=3,c=4', then the output is the two records 'a=1,b=2,c=' and .\} .nf (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for any array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. +Examples: Array example: any([10,20,30], func(e) {return $index == e}) Map example: any({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) .fi @@ -2428,6 +2432,7 @@ Map example: any({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) .\} .nf (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, applies the function to each element of the array/map. For arrays, the function should take one argument, for array element; it should return a new element. For maps, it should take two arguments, for map-element key and value; it should return a new key-value pair (i.e. a single-entry map). +Examples: Array example: apply([1,2,3,4,5], func(e) {return e ** 3}) returns [1, 8, 27, 64, 125]. Map example: apply({"a":1, "b":3, "c":5}, func(k,v) {return {toupper(k): v ** 2}}) returns {"A": 1, "B":9, "C": 25}", .fi @@ -2791,6 +2796,7 @@ Map example: apply({"a":1, "b":3, "c":5}, func(k,v) {return {toupper(k): v ** 2} .\} .nf (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, yields a boolean true if the argument function returns true for every array/map element, false otherwise. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. +Examples: Array example: every(["a", "b", "c"], func(e) {return $[e] >= 0}) Map example: every({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) .fi @@ -2820,8 +2826,9 @@ Map example: every({"a": "foo", "b": "bar"}, func(k,v) {return $[k] == v}) .\} .nf (class=collections #args=3) Flattens multi-level maps to single-level ones. Useful for nested JSON-like structures for non-JSON file formats like CSV. -Example: flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. -Example: flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. +Examples: +flatten("a", ".", {"b": { "c": 4 }}) is {"a.b.c" : 4}. +flatten("", ".", {"a": { "b": 3 }}) is {"a.b" : 3}. Two-argument version: flatten($*, ".") is the same as flatten("", ".", $*). .fi .if n \{\ @@ -2859,6 +2866,7 @@ Two-argument version: flatten($*, ".") is the same as flatten("", ".", $*). .\} .nf (class=higher-order-functions #args=3) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is taken from the third argument. +Examples: Array example: fold([1,2,3,4,5], func(acc,e) {return acc + e**3}, 10000) returns 10225. Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": accv+ev**2}}, {"sum":10000}) returns 10035. .fi @@ -2900,12 +2908,25 @@ Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": .fi .if n \{\ .RE +.SS "gmt2localtime" +.if n \{\ +.RS 0 +.\} +.nf + (class=time #args=1) Convert from a GMT-time string to a local-time string, consulting $TZ +Example: +gmt2localtime("1999-12-31T22:00:00Z") = "2000-01-01 00:00:00" with TZ="Asia/Istanbul" +.fi +.if n \{\ +.RE .SS "gmt2sec" .if n \{\ .RS 0 .\} .nf (class=time #args=1) Parses GMT timestamp as integer seconds since the epoch. +Example: +gmt2sec("2001-02-03T04:05:06Z") = 981173106 .fi .if n \{\ .RE @@ -2914,7 +2935,7 @@ Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": .RS 0 .\} .nf - (class=string #args=3) Example: '$name=gsub($name, "old", "new")' (replace all). + (class=string #args=3) '$name=gsub($name, "old", "new")' (replace all). .fi .if n \{\ .RE @@ -3158,8 +3179,9 @@ Map example: fold({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum": .\} .nf (class=conversion #args=2) Makes string from map/array keys. -Example: joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". -Example: joink([1,2,3], ",") = "1,2,3". +Examples: +joink({"a":3,"b":4,"c":5}, ",") = "a,b,c". +joink([1,2,3], ",") = "1,2,3". .fi .if n \{\ .RE @@ -3169,8 +3191,9 @@ Example: joink([1,2,3], ",") = "1,2,3". .\} .nf (class=conversion #args=3) Makes string from map/array key-value pairs. -Example: joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" -Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" +Examples: +joinkv([3,4,5], "=", ",") = "1=3,2=4,3=5" +joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" .fi .if n \{\ .RE @@ -3219,12 +3242,25 @@ Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" .fi .if n \{\ .RE +.SS "localtime2gmt" +.if n \{\ +.RS 0 +.\} +.nf + (class=time #args=1) Convert from a local-time string to a GMT-time string, consulting $TZ +Example: +localtime2gmt("2000-01-01 00:00:00") = "1999-12-31T22:00:00Z" with TZ="Asia/Istanbul" +.fi +.if n \{\ +.RE .SS "localtime2sec" .if n \{\ .RS 0 .\} .nf (class=time #args=1) Parses local timestamp as integer seconds since the epoch. Consults $TZ environment variable. +Example: +localtime2sec("2001-02-03 04:05:06") = 981165906 with TZ="Asia/Istanbul" .fi .if n \{\ .RE @@ -3405,6 +3441,7 @@ Example: joinkv({"a":3,"b":4,"c":5}, "=", ",") = "a=3,b=4,c=5" .\} .nf (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, accumulates entries into a final output -- for example, sum or product. For arrays, the function should take two arguments, for accumulated value and array element, and return the accumulated element. For maps, it should take four arguments, for accumulated key and value, and map-element key and value; it should return the updated accumulator as a new key-value pair (i.e. a single-entry map). The start value for the accumulator is the first element for arrays, or the first element's key-value pair for maps. +Examples: Array example: reduce([1,2,3,4,5], func(acc,e) {return acc + e**3}) returns 225. Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_of_squares": accv + ev**2}}) returns {"sum_of_squares": 35}. .fi @@ -3415,7 +3452,7 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ .RS 0 .\} .nf - (class=string #args=2) Example: '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' + (class=string #args=2) '$name=regextract($name, "[A-Z]{3}[0-9]{2}")' .fi .if n \{\ .RE @@ -3424,7 +3461,7 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ .RS 0 .\} .nf - (class=string #args=3) Example: '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' + (class=string #args=3) '$name=regextract_or_else($name, "[A-Z]{3}[0-9]{2}", "default")' .fi .if n \{\ .RE @@ -3469,7 +3506,11 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ .RS 0 .\} .nf - (class=time #args=1,2) Formats seconds since epoch (integer part) as GMT timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch as GMT timestamp. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part. +Examples: +sec2gmt(1234567890) = "2009-02-13T23:31:30Z" +sec2gmt(1234567890.123456) = "2009-02-13T23:31:30Z" +sec2gmt(1234567890.123456, 6) = "2009-02-13T23:31:30.123456Z" .fi .if n \{\ .RE @@ -3478,7 +3519,9 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ .RS 0 .\} .nf - (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. + (class=time #args=1) Formats seconds since epoch (integer part) as GMT timestamp with year-month-date. Leaves non-numbers as-is. +Example: +sec2gmtdate(1440768801.7) = "2015-08-28". .fi .if n \{\ .RE @@ -3496,7 +3539,9 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ .RS 0 .\} .nf - (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date, e.g. sec2gmtdate(1440768801.7) = "2015-08-28". Leaves non-numbers as-is. Consults $TZ environment variable. + (class=time #args=1) Formats seconds since epoch (integer part) as local timestamp with year-month-date. Leaves non-numbers as-is. Consults $TZ environment variable. +Example: +sec2localdate(1440768801.7) = "2015-08-28" with TZ="Asia/Istanbul" .fi .if n \{\ .RE @@ -3505,7 +3550,11 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ .RS 0 .\} .nf - (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp, e.g. sec2gmt(1440768801.7) = "2015-08-28T13:33:21Z". Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part + (class=time #args=1,2) Formats seconds since epoch (integer part) as local timestamp. Consults $TZ environment variable. Leaves non-numbers as-is. With second integer argument n, includes n decimal places for the seconds part +Examples: +sec2localtime(1234567890) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" +sec2localtime(1234567890.123456) = "2009-02-14 01:31:30" with TZ="Asia/Istanbul" +sec2localtime(1234567890.123456, 6) = "2009-02-14 01:31:30.123456" with TZ="Asia/Istanbul" .fi .if n \{\ .RE @@ -3515,6 +3564,7 @@ Map example: reduce({"a":1, "b":3, "c": 5}, func(acck,accv,ek,ev) {return {"sum_ .\} .nf (class=higher-order-functions #args=2) Given a map or array as first argument and a function as second argument, includes each input element in the output if the function returns true. For arrays, the function should take one argument, for array element; for maps, it should take two, for map-element key and value. In either case it should return a boolean. +Examples: Array example: select([1,2,3,4,5], func(e) {return e >= 3}) returns [3, 4, 5]. Map example: select({"a":1, "b":3, "c":5}, func(k,v) {return v >= 3}) returns {"b":3, "c": 5}. .fi @@ -3580,6 +3630,7 @@ Map example: select({"a":1, "b":3, "c":5}, func(k,v) {return v >= 3}) returns {" .\} .nf (class=higher-order-functions #args=1-2) Given a map or array as first argument and string flags or function as optional second argument, returns a sorted copy of the input. With one argument, sorts array elements naturally, and maps naturally by map keys. If the second argument is a string, it can contain any of "f" for lexical (default "n" for natural/numeric), "), "c" for case-folded lexical, and "r" for reversed/descending sort. If the second argument is a function, then for arrays it should take two arguments a and b, returning < 0, 0, or > 0 as a < b, a == b, or a > b respectively; for maps the function should take four arguments ak, av, bk, and bv, again returning < 0, 0, or > 0, using a and b's keys and values. +Examples: Array example: sort([5,2,3,1,4], func(a,b) {return b <=> a}) returns [5,4,3,2,1]. Map example: sort({"c":2,"a":3,"b":1}, func(ak,av,bk,bv) {return bv <=> av}) returns {"a":3,"c":2,"b":1}. .fi @@ -3591,7 +3642,8 @@ Map example: sort({"c":2,"a":3,"b":1}, func(ak,av,bk,bv) {return bv <=> av}) ret .\} .nf (class=conversion #args=2) Splits string into array with type inference. -Example: splita("3,4,5", ",") = [3,4,5] +Example: +splita("3,4,5", ",") = [3,4,5] .fi .if n \{\ .RE @@ -3601,7 +3653,8 @@ Example: splita("3,4,5", ",") = [3,4,5] .\} .nf (class=conversion #args=2) Splits string into array without type inference. -Example: splita("3,4,5", ",") = ["3","4","5"] +Example: +splita("3,4,5", ",") = ["3","4","5"] .fi .if n \{\ .RE @@ -3611,7 +3664,8 @@ Example: splita("3,4,5", ",") = ["3","4","5"] .\} .nf (class=conversion #args=3) Splits string by separators into map with type inference. -Example: splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} +Example: +splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} .fi .if n \{\ .RE @@ -3621,7 +3675,8 @@ Example: splitkv("a=3,b=4,c=5", "=", ",") = {"a":3,"b":4,"c":5} .\} .nf (class=conversion #args=3) Splits string by separators into map without type inference (keys and values are strings). -Example: splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} +Example: +splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} .fi .if n \{\ .RE @@ -3631,7 +3686,8 @@ Example: splitkvx("a=3,b=4,c=5", "=", ",") = {"a":"3","b":"4","c":"5"} .\} .nf (class=conversion #args=2) Splits string by separator into integer-indexed map with type inference. -Example: splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} +Example: +splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} .fi .if n \{\ .RE @@ -3641,7 +3697,8 @@ Example: splitnv("a,b,c", ",") = {"1":"a","2":"b","3":"c"} .\} .nf (class=conversion #args=2) Splits string by separator into integer-indexed map without type inference (values are strings). -Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} +Example: +splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} .fi .if n \{\ .RE @@ -3668,7 +3725,10 @@ Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} .RS 0 .\} .nf - (class=time #args=2) Formats seconds since the epoch as timestamp, e.g. strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z", and strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z". Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. + (class=time #args=2) Formats seconds since the epoch as timestamp. Format strings are as in the C library (please see "man strftime" on your system), with the Miller-specific addition of "%1S" through "%9S" which format the seconds with 1 through 9 decimal places, respectively. ("%S" uses no decimal places.) See also strftime_local. +Examples: +strftime(1440768801.7,"%Y-%m-%dT%H:%M:%SZ") = "2015-08-28T13:33:21Z" +strftime(1440768801.7,"%Y-%m-%dT%H:%M:%3SZ") = "2015-08-28T13:33:21.700Z" .fi .if n \{\ .RE @@ -3678,6 +3738,9 @@ Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} .\} .nf (class=time #args=2) Like strftime but consults the $TZ environment variable to get local time zone. +Examples: +strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%S %z") = "2015-08-28 16:33:21 +0300" with TZ="Asia/Istanbul" +strftime_local(1440768801.7, "%Y-%m-%d %H:%M:%3S %z") = "2015-08-28 16:33:21.700 +0300" with TZ="Asia/Istanbul" .fi .if n \{\ .RE @@ -3713,7 +3776,12 @@ Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} .RS 0 .\} .nf - (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch, e.g. strptime("2015-08-28T13:33:21Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000, and strptime("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000. See also strptime_local. + (class=time #args=2) strptime: Parses timestamp as floating-point seconds since the epoch. See also strptime_local. +Examples: +strptime("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.000000 +strptime("2015-08-28T13:33:21.345Z", "%Y-%m-%dT%H:%M:%SZ") = 1440768801.345000 +strptime("1970-01-01 00:00:00 -0400", "%Y-%m-%d %H:%M:%S %z") = 14400 +strptime("1970-01-01 00:00:00 EET", "%Y-%m-%d %H:%M:%S %Z") = -7200 .fi .if n \{\ .RE @@ -3723,6 +3791,10 @@ Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} .\} .nf (class=time #args=2) Like stpftime but consults the $TZ environment variable to get local time zone. +Examples: +strptime_local("2015-08-28T13:33:21Z", "%Y-%m-%dT%H:%M:%SZ") = 1440758001 with TZ="Asia/Istanbul" +strptime_local("2015-08-28T13:33:21.345Z","%Y-%m-%dT%H:%M:%SZ") = 1440758001.345 with TZ="Asia/Istanbul" +strptime_local("2015-08-28 13:33:21", "%Y-%m-%d %H:%M:%S") = 1440758001 with TZ="Asia/Istanbul" .fi .if n \{\ .RE @@ -3731,7 +3803,7 @@ Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} .RS 0 .\} .nf - (class=string #args=3) Example: '$name=sub($name, "old", "new")' (replace once). + (class=string #args=3) '$name=sub($name, "old", "new")' (replace once). .fi .if n \{\ .RE @@ -3849,7 +3921,8 @@ Example: splitnvx("3,4,5", ",") = {"1":"3","2":"4","3":"5"} .\} .nf (class=collections #args=2) Reverses flatten. Useful for nested JSON-like structures for non-JSON file formats like CSV. See also arrayify. -Example: unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. +Example: +unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. .fi .if n \{\ .RE @@ -3868,6 +3941,7 @@ Example: unflatten({"a.b.c" : 4}, ".") is {"a": "b": { "c": 4 }}. .\} .nf (class=math #args=0) Floating-point numbers uniformly distributed on the unit interval. +Example: Int-valued example: '$n=floor(20+urand()*11)'. .fi .if n \{\