From d852ec18900ef635a38f99ed769a636f15af72c6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 19 May 2017 12:35:36 -0500 Subject: 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. --- tests/date.test | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3