summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authordana <dana@dana.is>2018-12-29 05:22:34 -0600
committerdana <dana@dana.is>2018-12-29 05:24:25 -0600
commit162c198aabcdbe3795d34142c4707649f60fe499 (patch)
tree609bf48c39b34c288be4b3580bd9d70d1d4e583a /Test
parentf64cd71d442b0b7152131282dd7567be010edb78 (diff)
downloadzsh-162c198aabcdbe3795d34142c4707649f60fe499.tar.gz
zsh-162c198aabcdbe3795d34142c4707649f60fe499.tar.xz
zsh-162c198aabcdbe3795d34142c4707649f60fe499.zip
43953: Fix rounding/truncation error in %. time-format specifier
Also fixes an issue where %. couldn't be used more than once in a format
string without strange results

Tweaked very slightly per workers/43954
Diffstat (limited to 'Test')
-rw-r--r--Test/V09datetime.ztst16
1 files changed, 16 insertions, 0 deletions
diff --git a/Test/V09datetime.ztst b/Test/V09datetime.ztst
index 2041d9b40..9f67ecec3 100644
--- a/Test/V09datetime.ztst
+++ b/Test/V09datetime.ztst
@@ -114,3 +114,19 @@
 
   strftime -r '%Y' 2> /dev/null
 1:-r timestring not optional
+
+  # This tests rounding up and the use of repeated %.s
+  strftime '%Y-%m-%d %H:%M:%S.%3..%3.' 1012615322 $(( 999_999 ))
+  # These test the ceiling on rounding up
+  for 1 in %. %1. %3. %6. %9. %12.; do
+    print -rn - "$1 "
+    strftime "%Y-%m-%d %H:%M:%S.$1" 1012615322 $(( 999_999_999 ))
+  done
+0:%. truncation
+>2002-02-02 02:02:02.001.001
+>%. 2002-02-02 02:02:02.999
+>%1. 2002-02-02 02:02:02.9
+>%3. 2002-02-02 02:02:02.999
+>%6. 2002-02-02 02:02:02.999999
+>%9. 2002-02-02 02:02:02.999999999
+>%12. 2002-02-02 02:02:02.999999999