diff options
author | Rob Landley <rob@landley.net> | 2017-05-19 12:35:36 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2017-05-19 12:35:36 -0500 |
commit | d852ec18900ef635a38f99ed769a636f15af72c6 (patch) | |
tree | 48c34a2717618e39f494a8e7fe11786c71b83144 /tests | |
parent | 57605d2b481a87af4ba444761ece592d441950b1 (diff) | |
download | toybox-d852ec18900ef635a38f99ed769a636f15af72c6.tar.gz |
Implement date %N, loosely inspired by Elliott Hughes's patch.
I didn't implement %37N's ability to insert zeroes, so removed those
two tests. If you really need it, I can add the divide loop back.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/date.test | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/date.test b/tests/date.test index d59d7fcf..be80d451 100644 --- a/tests/date.test +++ b/tests/date.test @@ -21,3 +21,14 @@ testing "-d 111014312015.30" "TZ=UTC date -d 111014312015.30 2>&1" "Sun Nov 10 1 # Accidentally given a Unix time, we should trivially reject that. testing "Unix time missing @" "TZ=UTC date 1438053157 2>/dev/null || echo no" \ "no\n" "" "" + +# Test the %N extension to srtftime(3) format strings. +testing "%N" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%Y%m%d-%H%M%S.%N" "20120123-123456.123456789\n" "" "" +testing "%1N" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%Y%m%d-%H%M%S.%1N" "20120123-123456.1\n" "" "" +testing "%2N" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%Y%m%d-%H%M%S.%2N" "20120123-123456.12\n" "" "" +testing "%8N" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%Y%m%d-%H%M%S.%8N" "20120123-123456.12345678\n" "" "" +testing "%9N" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%Y%m%d-%H%M%S.%9N" "20120123-123456.123456789\n" "" "" +testing "%%N" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%Y%m%d-%H%M%S.%%N" "20120123-123456.%N\n" "" "" +testing "trailing %" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%Y%m%d-%H%M%S.%" "20120123-123456.%\n" "" "" +testing "just %" "touch -d 2012-01-23T12:34:56.123456789 f && date -r f +%" "%\n" "" "" +rm -f f |