diff options
author | Elliott Hughes <enh@google.com> | 2020-08-03 16:59:29 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-08-04 03:13:14 -0500 |
commit | babcb4bcf4c5c37e545f174db9ba99c62ebb877a (patch) | |
tree | c57469ee0dbfb12f4f85ed65bd5cdbbb28796cce /tests | |
parent | dc7654192c4b0c599cf5f742673a0829d6eddcd9 (diff) | |
download | toybox-babcb4bcf4c5c37e545f174db9ba99c62ebb877a.tar.gz |
xparsedate: support UTC offsets.
Requested in https://github.com/landley/toybox/issues/130, quoting an
old version of the toybox help. This is also supported by coreutils.
Set $LANG to C in the date tests so that they pass with TEST_HOST=1
(they were already failing for me, presumably related to a newer glibc).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/date.test | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/date.test b/tests/date.test index 2b865349..5cb9f038 100644 --- a/tests/date.test +++ b/tests/date.test @@ -9,6 +9,9 @@ tz=Europe/Berlin this_year=$(TZ=$tz date +%Y) +# Use a consistent locale too. +export LANG=C + # Unix date parsing. testing "-d @0" "TZ=$tz date -d @0" "Thu Jan 1 01:00:00 CET 1970\n" "" "" testing "-d @0x123 invalid" "TZ=$tz date -d @0x123 2>/dev/null || echo expected error" "expected error\n" "" "" @@ -54,3 +57,10 @@ rm -f f testing "TZ=" "TZ='America/Los_Angeles' date -d 'TZ=\"Europe/Berlin\" 2018-01-04 08:00'" "Wed Jan 3 23:00:00 PST 2018\n" "" "" testing "TZ=" "TZ='America/Los_Angeles' date -d 'TZ=\"Europe/Berlin\" 2018-10-04 08:00'" "Wed Oct 3 23:00:00 PDT 2018\n" "" "" testing "TZ= @" "TZ='America/Los_Angeles' date -d 'TZ=\"GMT\" @1533427200'" "Sat Aug 4 17:00:00 PDT 2018\n" "" "" + +testing "tz Z" \ + "date -u -d 2020-08-01T12:34:56Z" "Sat Aug 1 12:34:56 UTC 2020\n" "" "" +testing "tz +0800" \ + "date -u -d 2020-08-01T12:34:56+0800" "Sat Aug 1 04:34:56 UTC 2020\n" "" "" +testing "tz +08:00" \ + "date -u -d 2020-08-01T12:34:56+08:00" "Sat Aug 1 04:34:56 UTC 2020\n" "" "" |