summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authordana <dana@dana.is>2018-11-13 13:01:01 -0600
committerdana <dana@dana.is>2018-11-13 13:01:01 -0600
commit5ad76492af8931added1ae9600309d915d1427a5 (patch)
tree61450721cfc810d4154c1875c3519bc5927f8dbb /Test
parent0b3b52778bd7a4a2c97637c3d4739a7e66a695b1 (diff)
downloadzsh-5ad76492af8931added1ae9600309d915d1427a5.tar.gz
zsh-5ad76492af8931added1ae9600309d915d1427a5.tar.xz
zsh-5ad76492af8931added1ae9600309d915d1427a5.zip
43800: Add nanosecond support to strftime built-in
Diffstat (limited to 'Test')
-rw-r--r--Test/V09datetime.ztst29
1 files changed, 29 insertions, 0 deletions
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