aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/lisp/time-stamp-tests.el192
1 files changed, 97 insertions, 95 deletions
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index 4cc4ea1a5b8..d01d37a6648 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -29,7 +29,7 @@
29 (user-full-name "Time Stamp Tester") 29 (user-full-name "Time Stamp Tester")
30 (buffer-file-name "/emacs/test/time-stamped-file") 30 (buffer-file-name "/emacs/test/time-stamped-file")
31 (mail-host-address "test-mail-host-name") 31 (mail-host-address "test-mail-host-name")
32 (ref-time '(17337 16613)) ;Monday, Jan 2, 2006, 3:04:05 PM 32 (ref-time1 '(17337 16613)) ;Monday, Jan 2, 2006, 3:04:05 PM
33 (ref-time2 '(22574 61591)) ;Friday, Nov 18, 2016, 12:14:15 PM 33 (ref-time2 '(22574 61591)) ;Friday, Nov 18, 2016, 12:14:15 PM
34 (ref-time3 '(21377 34956)) ;Sunday, May 25, 2014, 06:07:08 AM 34 (ref-time3 '(21377 34956)) ;Sunday, May 25, 2014, 06:07:08 AM
35 (time-stamp-time-zone t)) ;use UTC 35 (time-stamp-time-zone t)) ;use UTC
@@ -41,7 +41,7 @@
41 (lambda () "test-system-name.example.org"))) 41 (lambda () "test-system-name.example.org")))
42 ;; Not all reference times are used in all tests; 42 ;; Not all reference times are used in all tests;
43 ;; suppress the byte compiler's "unused" warning. 43 ;; suppress the byte compiler's "unused" warning.
44 (list ref-time ref-time2 ref-time3) 44 (list ref-time1 ref-time2 ref-time3)
45 ,@body))) 45 ,@body)))
46(put 'with-time-stamp-test-env 'lisp-indent-hook 'defun) 46(put 'with-time-stamp-test-env 'lisp-indent-hook 'defun)
47 47
@@ -61,90 +61,90 @@
61 "Test time-stamp formats for named day of week." 61 "Test time-stamp formats for named day of week."
62 (with-time-stamp-test-env 62 (with-time-stamp-test-env
63 ;; implemented and documented since 1997 63 ;; implemented and documented since 1997
64 (should (equal (time-stamp-string "%3a" ref-time) "Mon")) 64 (should (equal (time-stamp-string "%3a" ref-time1) "Mon"))
65 (should (equal (time-stamp-string "%#A" ref-time) "MONDAY")) 65 (should (equal (time-stamp-string "%#A" ref-time1) "MONDAY"))
66 ;; documented 1997-2019 66 ;; documented 1997-2019
67 (should (equal (time-stamp-string "%3A" ref-time) "MON")) 67 (should (equal (time-stamp-string "%3A" ref-time1) "MON"))
68 (should (equal (time-stamp-string "%:a" ref-time) "Monday")) 68 (should (equal (time-stamp-string "%:a" ref-time1) "Monday"))
69 ;; implemented since 2001, documented since 2019 69 ;; implemented since 2001, documented since 2019
70 (should (equal (time-stamp-string "%#a" ref-time) "MON")) 70 (should (equal (time-stamp-string "%#a" ref-time1) "MON"))
71 (should (equal (time-stamp-string "%:A" ref-time) "Monday")) 71 (should (equal (time-stamp-string "%:A" ref-time1) "Monday"))
72 ;; allowed but undocumented since 2019 (warned 1997-2019) 72 ;; allowed but undocumented since 2019 (warned 1997-2019)
73 (should (equal (time-stamp-string "%^A" ref-time) "MONDAY")) 73 (should (equal (time-stamp-string "%^A" ref-time1) "MONDAY"))
74 ;; warned 1997-2019, changed in 2019 74 ;; warned 1997-2019, changed in 2019
75 (should (equal (time-stamp-string "%a" ref-time) "Mon")) 75 (should (equal (time-stamp-string "%a" ref-time1) "Mon"))
76 (should (equal (time-stamp-string "%^a" ref-time) "MON")) 76 (should (equal (time-stamp-string "%^a" ref-time1) "MON"))
77 (should (equal (time-stamp-string "%A" ref-time) "Monday")))) 77 (should (equal (time-stamp-string "%A" ref-time1) "Monday"))))
78 78
79(ert-deftest time-stamp-test-month-name () 79(ert-deftest time-stamp-test-month-name ()
80 "Test time-stamp formats for month name." 80 "Test time-stamp formats for month name."
81 (with-time-stamp-test-env 81 (with-time-stamp-test-env
82 ;; implemented and documented since 1997 82 ;; implemented and documented since 1997
83 (should (equal (time-stamp-string "%3b" ref-time) "Jan")) 83 (should (equal (time-stamp-string "%3b" ref-time1) "Jan"))
84 (should (equal (time-stamp-string "%#B" ref-time) "JANUARY")) 84 (should (equal (time-stamp-string "%#B" ref-time1) "JANUARY"))
85 ;; documented 1997-2019 85 ;; documented 1997-2019
86 (should (equal (time-stamp-string "%3B" ref-time) "JAN")) 86 (should (equal (time-stamp-string "%3B" ref-time1) "JAN"))
87 (should (equal (time-stamp-string "%:b" ref-time) "January")) 87 (should (equal (time-stamp-string "%:b" ref-time1) "January"))
88 ;; implemented since 2001, documented since 2019 88 ;; implemented since 2001, documented since 2019
89 (should (equal (time-stamp-string "%#b" ref-time) "JAN")) 89 (should (equal (time-stamp-string "%#b" ref-time1) "JAN"))
90 (should (equal (time-stamp-string "%:B" ref-time) "January")) 90 (should (equal (time-stamp-string "%:B" ref-time1) "January"))
91 ;; allowed but undocumented since 2019 (warned 1997-2019) 91 ;; allowed but undocumented since 2019 (warned 1997-2019)
92 (should (equal (time-stamp-string "%^B" ref-time) "JANUARY")) 92 (should (equal (time-stamp-string "%^B" ref-time1) "JANUARY"))
93 ;; warned 1997-2019, changed in 2019 93 ;; warned 1997-2019, changed in 2019
94 (should (equal (time-stamp-string "%b" ref-time) "Jan")) 94 (should (equal (time-stamp-string "%b" ref-time1) "Jan"))
95 (should (equal (time-stamp-string "%^b" ref-time) "JAN")) 95 (should (equal (time-stamp-string "%^b" ref-time1) "JAN"))
96 (should (equal (time-stamp-string "%B" ref-time) "January")))) 96 (should (equal (time-stamp-string "%B" ref-time1) "January"))))
97 97
98(ert-deftest time-stamp-test-day-of-month () 98(ert-deftest time-stamp-test-day-of-month ()
99 "Test time-stamp formats for day of month." 99 "Test time-stamp formats for day of month."
100 (with-time-stamp-test-env 100 (with-time-stamp-test-env
101 ;; implemented and documented since 1995 101 ;; implemented and documented since 1995
102 (should (equal (time-stamp-string "%2d" ref-time) " 2")) 102 (should (equal (time-stamp-string "%2d" ref-time1) " 2"))
103 (should (equal (time-stamp-string "%2d" ref-time2) "18")) 103 (should (equal (time-stamp-string "%2d" ref-time2) "18"))
104 (should (equal (time-stamp-string "%02d" ref-time) "02")) 104 (should (equal (time-stamp-string "%02d" ref-time1) "02"))
105 (should (equal (time-stamp-string "%02d" ref-time2) "18")) 105 (should (equal (time-stamp-string "%02d" ref-time2) "18"))
106 ;; documented 1997-2019 106 ;; documented 1997-2019
107 (should (equal (time-stamp-string "%:d" ref-time) "2")) 107 (should (equal (time-stamp-string "%:d" ref-time1) "2"))
108 (should (equal (time-stamp-string "%:d" ref-time2) "18")) 108 (should (equal (time-stamp-string "%:d" ref-time2) "18"))
109 ;; implemented since 1997, documented since 2019 109 ;; implemented since 1997, documented since 2019
110 (should (equal (time-stamp-string "%1d" ref-time) "2")) 110 (should (equal (time-stamp-string "%1d" ref-time1) "2"))
111 (should (equal (time-stamp-string "%1d" ref-time2) "18")) 111 (should (equal (time-stamp-string "%1d" ref-time2) "18"))
112 ;; allowed but undocumented since 2019 (warned 1997-2019) 112 ;; allowed but undocumented since 2019 (warned 1997-2019)
113 (should (equal (time-stamp-string "%-d" ref-time) "2")) 113 (should (equal (time-stamp-string "%-d" ref-time1) "2"))
114 (should (equal (time-stamp-string "%-d" ref-time2) "18")) 114 (should (equal (time-stamp-string "%-d" ref-time2) "18"))
115 ;; warned 1997-2019, changed in 2019 115 ;; warned 1997-2019, changed in 2019
116 (should (equal (time-stamp-string "%_d" ref-time) " 2")) 116 (should (equal (time-stamp-string "%_d" ref-time1) " 2"))
117 (should (equal (time-stamp-string "%_d" ref-time2) "18")) 117 (should (equal (time-stamp-string "%_d" ref-time2) "18"))
118 (should (equal (time-stamp-string "%d" ref-time) "02")) 118 (should (equal (time-stamp-string "%d" ref-time1) "02"))
119 (should (equal (time-stamp-string "%d" ref-time2) "18")))) 119 (should (equal (time-stamp-string "%d" ref-time2) "18"))))
120 120
121(ert-deftest time-stamp-test-hours-24 () 121(ert-deftest time-stamp-test-hours-24 ()
122 "Test time-stamp formats for hour on a 24-hour clock." 122 "Test time-stamp formats for hour on a 24-hour clock."
123 (with-time-stamp-test-env 123 (with-time-stamp-test-env
124 ;; implemented and documented since 1995 124 ;; implemented and documented since 1995
125 (should (equal (time-stamp-string "%2H" ref-time) "15")) 125 (should (equal (time-stamp-string "%2H" ref-time1) "15"))
126 (should (equal (time-stamp-string "%2H" ref-time2) "12")) 126 (should (equal (time-stamp-string "%2H" ref-time2) "12"))
127 (should (equal (time-stamp-string "%2H" ref-time3) " 6")) 127 (should (equal (time-stamp-string "%2H" ref-time3) " 6"))
128 (should (equal (time-stamp-string "%02H" ref-time) "15")) 128 (should (equal (time-stamp-string "%02H" ref-time1) "15"))
129 (should (equal (time-stamp-string "%02H" ref-time2) "12")) 129 (should (equal (time-stamp-string "%02H" ref-time2) "12"))
130 (should (equal (time-stamp-string "%02H" ref-time3) "06")) 130 (should (equal (time-stamp-string "%02H" ref-time3) "06"))
131 ;; documented 1997-2019 131 ;; documented 1997-2019
132 (should (equal (time-stamp-string "%:H" ref-time) "15")) 132 (should (equal (time-stamp-string "%:H" ref-time1) "15"))
133 (should (equal (time-stamp-string "%:H" ref-time2) "12")) 133 (should (equal (time-stamp-string "%:H" ref-time2) "12"))
134 (should (equal (time-stamp-string "%:H" ref-time3) "6")) 134 (should (equal (time-stamp-string "%:H" ref-time3) "6"))
135 ;; implemented since 1997, documented since 2019 135 ;; implemented since 1997, documented since 2019
136 (should (equal (time-stamp-string "%1H" ref-time) "15")) 136 (should (equal (time-stamp-string "%1H" ref-time1) "15"))
137 (should (equal (time-stamp-string "%1H" ref-time2) "12")) 137 (should (equal (time-stamp-string "%1H" ref-time2) "12"))
138 (should (equal (time-stamp-string "%1H" ref-time3) "6")) 138 (should (equal (time-stamp-string "%1H" ref-time3) "6"))
139 ;; allowed but undocumented since 2019 (warned 1997-2019) 139 ;; allowed but undocumented since 2019 (warned 1997-2019)
140 (should (equal (time-stamp-string "%-H" ref-time) "15")) 140 (should (equal (time-stamp-string "%-H" ref-time1) "15"))
141 (should (equal (time-stamp-string "%-H" ref-time2) "12")) 141 (should (equal (time-stamp-string "%-H" ref-time2) "12"))
142 (should (equal (time-stamp-string "%-H" ref-time3) "6")) 142 (should (equal (time-stamp-string "%-H" ref-time3) "6"))
143 ;; warned 1997-2019, changed in 2019 143 ;; warned 1997-2019, changed in 2019
144 (should (equal (time-stamp-string "%_H" ref-time) "15")) 144 (should (equal (time-stamp-string "%_H" ref-time1) "15"))
145 (should (equal (time-stamp-string "%_H" ref-time2) "12")) 145 (should (equal (time-stamp-string "%_H" ref-time2) "12"))
146 (should (equal (time-stamp-string "%_H" ref-time3) " 6")) 146 (should (equal (time-stamp-string "%_H" ref-time3) " 6"))
147 (should (equal (time-stamp-string "%H" ref-time) "15")) 147 (should (equal (time-stamp-string "%H" ref-time1) "15"))
148 (should (equal (time-stamp-string "%H" ref-time2) "12")) 148 (should (equal (time-stamp-string "%H" ref-time2) "12"))
149 (should (equal (time-stamp-string "%H" ref-time3) "06")))) 149 (should (equal (time-stamp-string "%H" ref-time3) "06"))))
150 150
@@ -152,29 +152,29 @@
152 "Test time-stamp formats for hour on a 12-hour clock." 152 "Test time-stamp formats for hour on a 12-hour clock."
153 (with-time-stamp-test-env 153 (with-time-stamp-test-env
154 ;; implemented and documented since 1995 154 ;; implemented and documented since 1995
155 (should (equal (time-stamp-string "%2I" ref-time) " 3")) 155 (should (equal (time-stamp-string "%2I" ref-time1) " 3"))
156 (should (equal (time-stamp-string "%2I" ref-time2) "12")) 156 (should (equal (time-stamp-string "%2I" ref-time2) "12"))
157 (should (equal (time-stamp-string "%2I" ref-time3) " 6")) 157 (should (equal (time-stamp-string "%2I" ref-time3) " 6"))
158 (should (equal (time-stamp-string "%02I" ref-time) "03")) 158 (should (equal (time-stamp-string "%02I" ref-time1) "03"))
159 (should (equal (time-stamp-string "%02I" ref-time2) "12")) 159 (should (equal (time-stamp-string "%02I" ref-time2) "12"))
160 (should (equal (time-stamp-string "%02I" ref-time3) "06")) 160 (should (equal (time-stamp-string "%02I" ref-time3) "06"))
161 ;; documented 1997-2019 161 ;; documented 1997-2019
162 (should (equal (time-stamp-string "%:I" ref-time) "3")) ;PM 162 (should (equal (time-stamp-string "%:I" ref-time1) "3")) ;PM
163 (should (equal (time-stamp-string "%:I" ref-time2) "12")) ;PM 163 (should (equal (time-stamp-string "%:I" ref-time2) "12")) ;PM
164 (should (equal (time-stamp-string "%:I" ref-time3) "6")) ;AM 164 (should (equal (time-stamp-string "%:I" ref-time3) "6")) ;AM
165 ;; implemented since 1997, documented since 2019 165 ;; implemented since 1997, documented since 2019
166 (should (equal (time-stamp-string "%1I" ref-time) "3")) 166 (should (equal (time-stamp-string "%1I" ref-time1) "3"))
167 (should (equal (time-stamp-string "%1I" ref-time2) "12")) 167 (should (equal (time-stamp-string "%1I" ref-time2) "12"))
168 (should (equal (time-stamp-string "%1I" ref-time3) "6")) 168 (should (equal (time-stamp-string "%1I" ref-time3) "6"))
169 ;; allowed but undocumented since 2019 (warned 1997-2019) 169 ;; allowed but undocumented since 2019 (warned 1997-2019)
170 (should (equal (time-stamp-string "%-I" ref-time) "3")) 170 (should (equal (time-stamp-string "%-I" ref-time1) "3"))
171 (should (equal (time-stamp-string "%-I" ref-time2) "12")) 171 (should (equal (time-stamp-string "%-I" ref-time2) "12"))
172 (should (equal (time-stamp-string "%-I" ref-time3) "6")) 172 (should (equal (time-stamp-string "%-I" ref-time3) "6"))
173 ;; warned 1997-2019, changed in 2019 173 ;; warned 1997-2019, changed in 2019
174 (should (equal (time-stamp-string "%_I" ref-time) " 3")) 174 (should (equal (time-stamp-string "%_I" ref-time1) " 3"))
175 (should (equal (time-stamp-string "%_I" ref-time2) "12")) 175 (should (equal (time-stamp-string "%_I" ref-time2) "12"))
176 (should (equal (time-stamp-string "%_I" ref-time3) " 6")) 176 (should (equal (time-stamp-string "%_I" ref-time3) " 6"))
177 (should (equal (time-stamp-string "%I" ref-time) "03")) 177 (should (equal (time-stamp-string "%I" ref-time1) "03"))
178 (should (equal (time-stamp-string "%I" ref-time2) "12")) 178 (should (equal (time-stamp-string "%I" ref-time2) "12"))
179 (should (equal (time-stamp-string "%I" ref-time3) "06")))) 179 (should (equal (time-stamp-string "%I" ref-time3) "06"))))
180 180
@@ -182,154 +182,156 @@
182 "Test time-stamp formats for month number." 182 "Test time-stamp formats for month number."
183 (with-time-stamp-test-env 183 (with-time-stamp-test-env
184 ;; implemented and documented since 1995 184 ;; implemented and documented since 1995
185 (should (equal (time-stamp-string "%2m" ref-time) " 1")) 185 (should (equal (time-stamp-string "%2m" ref-time1) " 1"))
186 (should (equal (time-stamp-string "%2m" ref-time2) "11")) 186 (should (equal (time-stamp-string "%2m" ref-time2) "11"))
187 (should (equal (time-stamp-string "%02m" ref-time) "01")) 187 (should (equal (time-stamp-string "%02m" ref-time1) "01"))
188 (should (equal (time-stamp-string "%02m" ref-time2) "11")) 188 (should (equal (time-stamp-string "%02m" ref-time2) "11"))
189 ;; documented 1997-2019 189 ;; documented 1997-2019
190 (should (equal (time-stamp-string "%:m" ref-time) "1")) 190 (should (equal (time-stamp-string "%:m" ref-time1) "1"))
191 (should (equal (time-stamp-string "%:m" ref-time2) "11")) 191 (should (equal (time-stamp-string "%:m" ref-time2) "11"))
192 ;; implemented since 1997, documented since 2019 192 ;; implemented since 1997, documented since 2019
193 (should (equal (time-stamp-string "%1m" ref-time) "1")) 193 (should (equal (time-stamp-string "%1m" ref-time1) "1"))
194 (should (equal (time-stamp-string "%1m" ref-time2) "11")) 194 (should (equal (time-stamp-string "%1m" ref-time2) "11"))
195 ;; allowed but undocumented since 2019 (warned 1997-2019) 195 ;; allowed but undocumented since 2019 (warned 1997-2019)
196 (should (equal (time-stamp-string "%-m" ref-time) "1")) 196 (should (equal (time-stamp-string "%-m" ref-time1) "1"))
197 (should (equal (time-stamp-string "%-m" ref-time2) "11")) 197 (should (equal (time-stamp-string "%-m" ref-time2) "11"))
198 ;; warned 1997-2019, changed in 2019 198 ;; warned 1997-2019, changed in 2019
199 (should (equal (time-stamp-string "%_m" ref-time) " 1")) 199 (should (equal (time-stamp-string "%_m" ref-time1) " 1"))
200 (should (equal (time-stamp-string "%_m" ref-time2) "11")) 200 (should (equal (time-stamp-string "%_m" ref-time2) "11"))
201 (should (equal (time-stamp-string "%m" ref-time) "01")) 201 (should (equal (time-stamp-string "%m" ref-time1) "01"))
202 (should (equal (time-stamp-string "%m" ref-time2) "11")))) 202 (should (equal (time-stamp-string "%m" ref-time2) "11"))))
203 203
204(ert-deftest time-stamp-test-minute () 204(ert-deftest time-stamp-test-minute ()
205 "Test time-stamp formats for minute." 205 "Test time-stamp formats for minute."
206 (with-time-stamp-test-env 206 (with-time-stamp-test-env
207 ;; implemented and documented since 1995 207 ;; implemented and documented since 1995
208 (should (equal (time-stamp-string "%2M" ref-time) " 4")) 208 (should (equal (time-stamp-string "%2M" ref-time1) " 4"))
209 (should (equal (time-stamp-string "%2M" ref-time2) "14")) 209 (should (equal (time-stamp-string "%2M" ref-time2) "14"))
210 (should (equal (time-stamp-string "%02M" ref-time) "04")) 210 (should (equal (time-stamp-string "%02M" ref-time1) "04"))
211 (should (equal (time-stamp-string "%02M" ref-time2) "14")) 211 (should (equal (time-stamp-string "%02M" ref-time2) "14"))
212 ;; documented 1997-2019 212 ;; documented 1997-2019
213 (should (equal (time-stamp-string "%:M" ref-time) "4")) 213 (should (equal (time-stamp-string "%:M" ref-time1) "4"))
214 (should (equal (time-stamp-string "%:M" ref-time2) "14")) 214 (should (equal (time-stamp-string "%:M" ref-time2) "14"))
215 ;; implemented since 1997, documented since 2019 215 ;; implemented since 1997, documented since 2019
216 (should (equal (time-stamp-string "%1M" ref-time) "4")) 216 (should (equal (time-stamp-string "%1M" ref-time1) "4"))
217 (should (equal (time-stamp-string "%1M" ref-time2) "14")) 217 (should (equal (time-stamp-string "%1M" ref-time2) "14"))
218 ;; allowed but undocumented since 2019 (warned 1997-2019) 218 ;; allowed but undocumented since 2019 (warned 1997-2019)
219 (should (equal (time-stamp-string "%-M" ref-time) "4")) 219 (should (equal (time-stamp-string "%-M" ref-time1) "4"))
220 (should (equal (time-stamp-string "%-M" ref-time2) "14")) 220 (should (equal (time-stamp-string "%-M" ref-time2) "14"))
221 ;; warned 1997-2019, changed in 2019 221 ;; warned 1997-2019, changed in 2019
222 (should (equal (time-stamp-string "%_M" ref-time) " 4")) 222 (should (equal (time-stamp-string "%_M" ref-time1) " 4"))
223 (should (equal (time-stamp-string "%_M" ref-time2) "14")) 223 (should (equal (time-stamp-string "%_M" ref-time2) "14"))
224 (should (equal (time-stamp-string "%M" ref-time) "04")) 224 (should (equal (time-stamp-string "%M" ref-time1) "04"))
225 (should (equal (time-stamp-string "%M" ref-time2) "14")))) 225 (should (equal (time-stamp-string "%M" ref-time2) "14"))))
226 226
227(ert-deftest time-stamp-test-second () 227(ert-deftest time-stamp-test-second ()
228 "Test time-stamp formats for second." 228 "Test time-stamp formats for second."
229 (with-time-stamp-test-env 229 (with-time-stamp-test-env
230 ;; implemented and documented since 1995 230 ;; implemented and documented since 1995
231 (should (equal (time-stamp-string "%2S" ref-time) " 5")) 231 (should (equal (time-stamp-string "%2S" ref-time1) " 5"))
232 (should (equal (time-stamp-string "%2S" ref-time2) "15")) 232 (should (equal (time-stamp-string "%2S" ref-time2) "15"))
233 (should (equal (time-stamp-string "%02S" ref-time) "05")) 233 (should (equal (time-stamp-string "%02S" ref-time1) "05"))
234 (should (equal (time-stamp-string "%02S" ref-time2) "15")) 234 (should (equal (time-stamp-string "%02S" ref-time2) "15"))
235 ;; documented 1997-2019 235 ;; documented 1997-2019
236 (should (equal (time-stamp-string "%:S" ref-time) "5")) 236 (should (equal (time-stamp-string "%:S" ref-time1) "5"))
237 (should (equal (time-stamp-string "%:S" ref-time2) "15")) 237 (should (equal (time-stamp-string "%:S" ref-time2) "15"))
238 ;; implemented since 1997, documented since 2019 238 ;; implemented since 1997, documented since 2019
239 (should (equal (time-stamp-string "%1S" ref-time) "5")) 239 (should (equal (time-stamp-string "%1S" ref-time1) "5"))
240 (should (equal (time-stamp-string "%1S" ref-time2) "15")) 240 (should (equal (time-stamp-string "%1S" ref-time2) "15"))
241 ;; allowed but undocumented since 2019 (warned 1997-2019) 241 ;; allowed but undocumented since 2019 (warned 1997-2019)
242 (should (equal (time-stamp-string "%-S" ref-time) "5")) 242 (should (equal (time-stamp-string "%-S" ref-time1) "5"))
243 (should (equal (time-stamp-string "%-S" ref-time2) "15")) 243 (should (equal (time-stamp-string "%-S" ref-time2) "15"))
244 ;; warned 1997-2019, changed in 2019 244 ;; warned 1997-2019, changed in 2019
245 (should (equal (time-stamp-string "%_S" ref-time) " 5")) 245 (should (equal (time-stamp-string "%_S" ref-time1) " 5"))
246 (should (equal (time-stamp-string "%_S" ref-time2) "15")) 246 (should (equal (time-stamp-string "%_S" ref-time2) "15"))
247 (should (equal (time-stamp-string "%S" ref-time) "05")) 247 (should (equal (time-stamp-string "%S" ref-time1) "05"))
248 (should (equal (time-stamp-string "%S" ref-time2) "15")))) 248 (should (equal (time-stamp-string "%S" ref-time2) "15"))))
249 249
250(ert-deftest time-stamp-test-year-2digit () 250(ert-deftest time-stamp-test-year-2digit ()
251 "Test time-stamp formats for %y." 251 "Test time-stamp formats for %y."
252 (with-time-stamp-test-env 252 (with-time-stamp-test-env
253 ;; implemented and documented since 1995 253 ;; implemented and documented since 1995
254 (should (equal (time-stamp-string "%02y" ref-time) "06")) 254 (should (equal (time-stamp-string "%02y" ref-time1) "06"))
255 (should (equal (time-stamp-string "%02y" ref-time2) "16")) 255 (should (equal (time-stamp-string "%02y" ref-time2) "16"))
256 ;; documented 1997-2019 256 ;; documented 1997-2019
257 (should (equal (time-stamp-string "%:y" ref-time) "2006")) 257 (should (equal (time-stamp-string "%:y" ref-time1) "2006"))
258 (should (equal (time-stamp-string "%:y" ref-time2) "2016")) 258 (should (equal (time-stamp-string "%:y" ref-time2) "2016"))
259 ;; warned 1997-2019, changed in 2019 259 ;; warned 1997-2019, changed in 2019
260 ;; (We don't expect the %-y or %_y form to be useful, 260 ;; (We don't expect the %-y or %_y form to be useful,
261 ;; but we test both so that we can confidently state that 261 ;; but we test both so that we can confidently state that
262 ;; `-' and `_' affect all 2-digit conversions identically.) 262 ;; `-' and `_' affect all 2-digit conversions identically.)
263 (should (equal (time-stamp-string "%-y" ref-time) "6")) 263 (should (equal (time-stamp-string "%-y" ref-time1) "6"))
264 (should (equal (time-stamp-string "%-y" ref-time2) "16")) 264 (should (equal (time-stamp-string "%-y" ref-time2) "16"))
265 (should (equal (time-stamp-string "%_y" ref-time) " 6")) 265 (should (equal (time-stamp-string "%_y" ref-time1) " 6"))
266 (should (equal (time-stamp-string "%_y" ref-time2) "16")) 266 (should (equal (time-stamp-string "%_y" ref-time2) "16"))
267 (should (equal (time-stamp-string "%y" ref-time) "06")) 267 (should (equal (time-stamp-string "%y" ref-time1) "06"))
268 (should (equal (time-stamp-string "%y" ref-time2) "16")) 268 (should (equal (time-stamp-string "%y" ref-time2) "16"))
269 ;; implemented since 1995, warned since 2019, will change 269 ;; implemented since 1995, warned since 2019, will change
270 (time-stamp-should-warn (equal (time-stamp-string "%04y" ref-time) "2006")) 270 (time-stamp-should-warn
271 (time-stamp-should-warn (equal (time-stamp-string "%4y" ref-time) "2006")))) 271 (equal (time-stamp-string "%04y" ref-time1) "2006"))
272 (time-stamp-should-warn
273 (equal (time-stamp-string "%4y" ref-time1) "2006"))))
272 274
273(ert-deftest time-stamp-test-year-4digit () 275(ert-deftest time-stamp-test-year-4digit ()
274 "Test time-stamp format %Y." 276 "Test time-stamp format %Y."
275 (with-time-stamp-test-env 277 (with-time-stamp-test-env
276 ;; implemented since 1997, documented since 2019 278 ;; implemented since 1997, documented since 2019
277 (should (equal (time-stamp-string "%Y" ref-time) "2006")))) 279 (should (equal (time-stamp-string "%Y" ref-time1) "2006"))))
278 280
279(ert-deftest time-stamp-test-am-pm () 281(ert-deftest time-stamp-test-am-pm ()
280 "Test time-stamp formats for AM and PM strings." 282 "Test time-stamp formats for AM and PM strings."
281 (with-time-stamp-test-env 283 (with-time-stamp-test-env
282 ;; implemented and documented since 1997 284 ;; implemented and documented since 1997
283 (should (equal (time-stamp-string "%#p" ref-time) "pm")) 285 (should (equal (time-stamp-string "%#p" ref-time1) "pm"))
284 (should (equal (time-stamp-string "%#p" ref-time3) "am")) 286 (should (equal (time-stamp-string "%#p" ref-time3) "am"))
285 (should (equal (time-stamp-string "%P" ref-time) "PM")) 287 (should (equal (time-stamp-string "%P" ref-time1) "PM"))
286 (should (equal (time-stamp-string "%P" ref-time3) "AM")) 288 (should (equal (time-stamp-string "%P" ref-time3) "AM"))
287 ;; warned 1997-2019, changed in 2019 289 ;; warned 1997-2019, changed in 2019
288 (should (equal (time-stamp-string "%p" ref-time) "PM")) 290 (should (equal (time-stamp-string "%p" ref-time1) "PM"))
289 (should (equal (time-stamp-string "%p" ref-time3) "AM")))) 291 (should (equal (time-stamp-string "%p" ref-time3) "AM"))))
290 292
291(ert-deftest time-stamp-test-day-number-in-week () 293(ert-deftest time-stamp-test-day-number-in-week ()
292 "Test time-stamp formats for day number in week." 294 "Test time-stamp formats for day number in week."
293 (with-time-stamp-test-env 295 (with-time-stamp-test-env
294 (should (equal (time-stamp-string "%w" ref-time) "1")) 296 (should (equal (time-stamp-string "%w" ref-time1) "1"))
295 (should (equal (time-stamp-string "%w" ref-time2) "5")) 297 (should (equal (time-stamp-string "%w" ref-time2) "5"))
296 (should (equal (time-stamp-string "%w" ref-time3) "0")))) 298 (should (equal (time-stamp-string "%w" ref-time3) "0"))))
297 299
298(ert-deftest time-stamp-test-time-zone () 300(ert-deftest time-stamp-test-time-zone ()
299 "Test time-stamp formats for time zone." 301 "Test time-stamp formats for time zone."
300 (with-time-stamp-test-env 302 (with-time-stamp-test-env
301 (let ((UTC-abbr (format-time-string "%Z" ref-time t)) 303 (let ((UTC-abbr (format-time-string "%Z" ref-time1 t))
302 (utc-abbr (format-time-string "%#Z" ref-time t))) 304 (utc-abbr (format-time-string "%#Z" ref-time1 t)))
303 ;; implemented and documented since 1995 305 ;; implemented and documented since 1995
304 (should (equal (time-stamp-string "%Z" ref-time) UTC-abbr)) 306 (should (equal (time-stamp-string "%Z" ref-time1) UTC-abbr))
305 ;; documented 1995-2019 307 ;; documented 1995-2019
306 (should (equal (time-stamp-string "%z" ref-time) utc-abbr)) 308 (should (equal (time-stamp-string "%z" ref-time1) utc-abbr))
307 ;; implemented since 1997, documented since 2019 309 ;; implemented since 1997, documented since 2019
308 (should (equal (time-stamp-string "%#Z" ref-time) utc-abbr))))) 310 (should (equal (time-stamp-string "%#Z" ref-time1) utc-abbr)))))
309 311
310(ert-deftest time-stamp-test-non-date-conversions () 312(ert-deftest time-stamp-test-non-date-conversions ()
311 "Test time-stamp formats for non-date items." 313 "Test time-stamp formats for non-date items."
312 (with-time-stamp-test-env 314 (with-time-stamp-test-env
313 ;; implemented and documented since 1995 315 ;; implemented and documented since 1995
314 (should (equal (time-stamp-string "%%" ref-time) "%")) ;% last char 316 (should (equal (time-stamp-string "%%" ref-time1) "%")) ;% last char
315 (should (equal (time-stamp-string "%%P" ref-time) "%P")) ;% not last char 317 (should (equal (time-stamp-string "%%P" ref-time1) "%P")) ;% not last char
316 (should (equal (time-stamp-string "%f" ref-time) "time-stamped-file")) 318 (should (equal (time-stamp-string "%f" ref-time1) "time-stamped-file"))
317 (should (equal 319 (should
318 (time-stamp-string "%F" ref-time) "/emacs/test/time-stamped-file")) 320 (equal (time-stamp-string "%F" ref-time1) "/emacs/test/time-stamped-file"))
319 (should (equal (time-stamp-string "%h" ref-time) "test-mail-host-name")) 321 (should (equal (time-stamp-string "%h" ref-time1) "test-mail-host-name"))
320 ;; documented 1995-2019 322 ;; documented 1995-2019
321 (should (equal 323 (should (equal
322 (time-stamp-string "%s" ref-time) "test-system-name.example.org")) 324 (time-stamp-string "%s" ref-time1) "test-system-name.example.org"))
323 (should (equal (time-stamp-string "%U" ref-time) "Time Stamp Tester")) 325 (should (equal (time-stamp-string "%U" ref-time1) "Time Stamp Tester"))
324 (should (equal (time-stamp-string "%u" ref-time) "test-logname")) 326 (should (equal (time-stamp-string "%u" ref-time1) "test-logname"))
325 ;; implemented since 2001, documented since 2019 327 ;; implemented since 2001, documented since 2019
326 (should (equal (time-stamp-string "%L" ref-time) "Time Stamp Tester")) 328 (should (equal (time-stamp-string "%L" ref-time1) "Time Stamp Tester"))
327 (should (equal (time-stamp-string "%l" ref-time) "test-logname")) 329 (should (equal (time-stamp-string "%l" ref-time1) "test-logname"))
328 ;; implemented since 2007, documented since 2019 330 ;; implemented since 2007, documented since 2019
329 (should (equal 331 (should (equal
330 (time-stamp-string "%Q" ref-time) "test-system-name.example.org")) 332 (time-stamp-string "%Q" ref-time1) "test-system-name.example.org"))
331 (should (equal 333 (should (equal
332 (time-stamp-string "%q" ref-time) "test-system-name")))) 334 (time-stamp-string "%q" ref-time1) "test-system-name"))))
333 335
334(ert-deftest time-stamp-test-ignored-modifiers () 336(ert-deftest time-stamp-test-ignored-modifiers ()
335 "Test additional args allowed (but ignored) to allow for future expansion." 337 "Test additional args allowed (but ignored) to allow for future expansion."
@@ -342,7 +344,7 @@
342(ert-deftest time-stamp-test-non-conversions () 344(ert-deftest time-stamp-test-non-conversions ()
343 "Test that without a %, the text is copied literally." 345 "Test that without a %, the text is copied literally."
344 (with-time-stamp-test-env 346 (with-time-stamp-test-env
345 (should (equal (time-stamp-string "No percent" ref-time) "No percent")))) 347 (should (equal (time-stamp-string "No percent" ref-time1) "No percent"))))
346 348
347(ert-deftest time-stamp-test-string-width () 349(ert-deftest time-stamp-test-string-width ()
348 "Test time-stamp string width modifiers." 350 "Test time-stamp string width modifiers."