Created
July 9, 2021 06:04
-
-
Save torbiak/fa13086f207b244e348a46c77d71ece6 to your computer and use it in GitHub Desktop.
Test mlr strptime against GNU date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
export TZ=America/Sao_Paulo | |
test_strptime_local() { | |
printf "\n$FUNCNAME\n" | |
local dates="\ | |
2017-02-18 23:00:00 | |
2017-02-18 23:59:59 | |
2017-02-19 00:00:00 | |
2017-02-19 00:30:00 | |
2017-02-19 01:00:00 | |
2017-10-14 23:00:00 | |
2017-10-14 23:59:59 | |
2017-10-15 00:00:00 | |
2017-10-15 00:30:00 | |
2017-10-15 01:00:00" | |
diff -u <(date -f - +%s <<<"$dates") <(mlr --nidx --ifs tab put '$1 = int(strptime_local($1, "%Y-%m-%d %H:%M:%S"));' <<<"$dates") | |
} | |
test_strptime_local || true | |
test_localtime2sec() { | |
printf "\n$FUNCNAME\n" | |
local dates="\ | |
2017-02-14 00:00:00 | |
2017-02-15 00:00:00 | |
2017-02-16 00:00:00 | |
2017-02-17 00:00:00 | |
2017-02-18 00:00:00 | |
2017-02-19 00:00:00 | |
2017-02-20 00:00:00 | |
2017-10-12 00:00:00 | |
2017-10-13 00:00:00 | |
2017-10-14 00:00:00 | |
2017-10-15 00:00:00 | |
2017-10-16 00:00:00 | |
2017-10-17 00:00:00 | |
2017-10-18 00:00:00 | |
2017-10-19 00:00:00" | |
diff -u <(date -f - +%s <<<"$dates") <(mlr --nidx --ifs tab put '$1 = int(localtime2sec($1));' <<<"$dates") | |
} | |
test_localtime2sec || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment