From 5ad76492af8931added1ae9600309d915d1427a5 Mon Sep 17 00:00:00 2001 From: dana Date: Tue, 13 Nov 2018 13:01:01 -0600 Subject: 43800: Add nanosecond support to strftime built-in --- Test/V09datetime.ztst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'Test') diff --git a/Test/V09datetime.ztst b/Test/V09datetime.ztst index ffad96c04..22d560750 100644 --- a/Test/V09datetime.ztst +++ b/Test/V09datetime.ztst @@ -82,3 +82,32 @@ # The result can be '%@' (Linux), '@' (BSDs) or an error (Cygwin). [[ $(strftime '%@' 0 2> /dev/null) == (%|)@ || $? != 0 ]] 0:bad format specifier + +# This test may fail at 23:59:59.xxx on New Year's Eve :/ + [[ "$( strftime '%Y' )" == "$( strftime '%Y' "$EPOCHSECONDS" )" ]] +0:epochtime optional + + strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 + strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 0 + strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 2 + strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 $(( 222 * (10 ** 9) )) +0:optional nanoseconds +>2002-02-02 02:02:02.000 +>2002-02-02 02:02:02.000 +>2002-02-02 02:02:02.000 +>2002-02-02 02:02:02.222 + + strftime '%Y' '' 2> /dev/null +1:empty epochtime not allowed + + strftime '%Y' 1012615322 '' 2> /dev/null +1:empty nanoseconds not allowed + + strftime '%N' 1012615322 ${(l<64><9>):-} 2> /dev/null +1:overflowed nanoseconds not allowed + + strftime '%N' 1012615322 -1 2> /dev/null +1:negative nanoseconds not allowed + + strftime -r '%Y' 2> /dev/null +1:-r timestring not optional -- cgit 1.4.1