1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// TODO(mordante) Investigate
10// UNSUPPORTED: apple-clang
11
12// UNSUPPORTED: c++03, c++11, c++14, c++17
13// UNSUPPORTED: no-localization
14// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
15
16// TODO FMT This test should not require std::to_chars(floating-point)
17// XFAIL: availability-fp_to_chars-missing
18
19// REQUIRES: locale.fr_FR.UTF-8
20// REQUIRES: locale.ja_JP.UTF-8
21
22// <chrono>
23//
24// template<class charT> struct formatter<chrono::file_time, charT>;
25
26#include <chrono>
27#include <format>
28
29#include <cassert>
30#include <concepts>
31#include <locale>
32#include <iostream>
33#include <type_traits>
34
35#include "formatter_tests.h"
36#include "make_string.h"
37#include "platform_support.h" // locale name macros
38#include "test_macros.h"
39
40// Modeled after the system clock's usings, this make adapting the
41// tests easier.
42template <class Duration>
43using file_time = std::chrono::time_point<std::chrono::file_clock, Duration>;
44using file_seconds = file_time<std::chrono::seconds>;
45using file_days = file_time<std::chrono::days>;
46
47template <class CharT>
48static void test_no_chrono_specs() {
49 using namespace std::literals::chrono_literals;
50
51 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
52
53 // Non localized output
54
55 // [time.syn]
56 // using nanoseconds = duration<signed integer type of at least 64 bits, nano>;
57 // using microseconds = duration<signed integer type of at least 55 bits, micro>;
58 // using milliseconds = duration<signed integer type of at least 45 bits, milli>;
59 // using seconds = duration<signed integer type of at least 35 bits>;
60 // using minutes = duration<signed integer type of at least 29 bits, ratio< 60>>;
61 // using hours = duration<signed integer type of at least 23 bits, ratio<3600>>;
62 check(SV("1425-08-04 22:06:56"), SV("{}"), file_seconds(-17'179'869'184s)); // Minimum value for 35 bits.
63 check(SV("1901-12-13 20:45:52"), SV("{}"), file_seconds(-2'147'483'648s));
64
65 check(SV("1969-12-31 00:00:00"), SV("{}"), file_seconds(-24h));
66 check(SV("1969-12-31 06:00:00"), SV("{}"), file_seconds(-18h));
67 check(SV("1969-12-31 12:00:00"), SV("{}"), file_seconds(-12h));
68 check(SV("1969-12-31 18:00:00"), SV("{}"), file_seconds(-6h));
69 check(SV("1969-12-31 23:59:59"), SV("{}"), file_seconds(-1s));
70
71 check(SV("1970-01-01 00:00:00"), SV("{}"), file_seconds(0s));
72 check(SV("2000-01-01 00:00:00"), SV("{}"), file_seconds(946'684'800s));
73 check(SV("2000-01-01 01:02:03"), SV("{}"), file_seconds(946'688'523s));
74
75 check(SV("2038-01-19 03:14:07"), SV("{}"), file_seconds(2'147'483'647s));
76 check(SV("2514-05-30 01:53:03"), SV("{}"), file_seconds(17'179'869'183s)); // Maximum value for 35 bits.
77
78 check(SV("2000-01-01 01:02:03.123"), SV("{}"), file_time<std::chrono::milliseconds>(946'688'523'123ms));
79
80 std::locale::global(loc: std::locale::classic());
81}
82
83template <class CharT>
84static void test_valid_values_year() {
85 using namespace std::literals::chrono_literals;
86
87 constexpr std::basic_string_view<CharT> fmt =
88 SV("{:%%C='%C'%t%%EC='%EC'%t%%y='%y'%t%%Oy='%Oy'%t%%Ey='%Ey'%t%%Y='%Y'%t%%EY='%EY'%n}");
89 constexpr std::basic_string_view<CharT> lfmt =
90 SV("{:L%%C='%C'%t%%EC='%EC'%t%%y='%y'%t%%Oy='%Oy'%t%%Ey='%Ey'%t%%Y='%Y'%t%%EY='%EY'%n}");
91
92 const std::locale loc(LOCALE_ja_JP_UTF_8);
93 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
94
95 // Non localized output using C-locale
96 check(SV("%C='19'\t%EC='19'\t%y='70'\t%Oy='70'\t%Ey='70'\t%Y='1970'\t%EY='1970'\n"),
97 fmt,
98 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
99
100 check(SV("%C='20'\t%EC='20'\t%y='09'\t%Oy='09'\t%Ey='09'\t%Y='2009'\t%EY='2009'\n"),
101 fmt,
102 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
103
104 // Use the global locale (fr_FR)
105 check(SV("%C='19'\t%EC='19'\t%y='70'\t%Oy='70'\t%Ey='70'\t%Y='1970'\t%EY='1970'\n"),
106 lfmt,
107 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
108
109 check(SV("%C='20'\t%EC='20'\t%y='09'\t%Oy='09'\t%Ey='09'\t%Y='2009'\t%EY='2009'\n"),
110 lfmt,
111 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
112
113 // Use supplied locale (ja_JP). This locale has a different alternate.
114#if defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
115
116 check(loc,
117 SV("%C='19'\t%EC='19'\t%y='70'\t%Oy='70'\t%Ey='70'\t%Y='1970'\t%EY='1970'\n"),
118 lfmt,
119 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
120
121 check(loc,
122 SV("%C='20'\t%EC='20'\t%y='09'\t%Oy='09'\t%Ey='09'\t%Y='2009'\t%EY='2009'\n"),
123 lfmt,
124 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
125#else // defined(_WIN32) || defined(__APPLE__) || defined(_AIX)|| defined(__FreeBSD__)
126
127 check(loc,
128 SV("%C='19'\t%EC='昭和'\t%y='70'\t%Oy='七十'\t%Ey='45'\t%Y='1970'\t%EY='昭和45年'\n"),
129 lfmt,
130 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
131
132 check(loc,
133 SV("%C='20'\t%EC='平成'\t%y='09'\t%Oy='九'\t%Ey='21'\t%Y='2009'\t%EY='平成21年'\n"),
134 lfmt,
135 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
136#endif // defined(_WIN32) || defined(__APPLE__) || defined(_AIX)|| defined(__FreeBSD__)
137
138 std::locale::global(loc: std::locale::classic());
139}
140
141template <class CharT>
142static void test_valid_values_month() {
143 using namespace std::literals::chrono_literals;
144
145 constexpr std::basic_string_view<CharT> fmt = SV("{:%%b='%b'%t%%h='%h'%t%%B='%B'%t%%m='%m'%t%%Om='%Om'%n}");
146 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%b='%b'%t%%h='%h'%t%%B='%B'%t%%m='%m'%t%%Om='%Om'%n}");
147
148 const std::locale loc(LOCALE_ja_JP_UTF_8);
149 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
150
151 // Non localized output using C-locale
152 check(SV("%b='Jan'\t%h='Jan'\t%B='January'\t%m='01'\t%Om='01'\n"),
153 fmt,
154 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
155
156 check(SV("%b='May'\t%h='May'\t%B='May'\t%m='05'\t%Om='05'\n"),
157 fmt,
158 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
159
160 // Use the global locale (fr_FR)
161#if defined(__APPLE__)
162 check(SV("%b='jan'\t%h='jan'\t%B='janvier'\t%m='01'\t%Om='01'\n"),
163 lfmt,
164 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
165#else
166 check(SV("%b='janv.'\t%h='janv.'\t%B='janvier'\t%m='01'\t%Om='01'\n"),
167 lfmt,
168 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
169#endif
170
171 check(SV("%b='mai'\t%h='mai'\t%B='mai'\t%m='05'\t%Om='05'\n"),
172 lfmt,
173 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
174
175 // Use supplied locale (ja_JP). This locale has a different alternate.
176#ifdef _WIN32
177 check(loc,
178 SV("%b='1'\t%h='1'\t%B='1月'\t%m='01'\t%Om='01'\n"),
179 lfmt,
180 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
181
182 check(loc,
183 SV("%b='5'\t%h='5'\t%B='5月'\t%m='05'\t%Om='05'\n"),
184 lfmt,
185 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
186#elif defined(_AIX) // _WIN32
187 check(loc,
188 SV("%b='1月'\t%h='1月'\t%B='1月'\t%m='01'\t%Om='01'\n"),
189 lfmt,
190 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
191
192 check(loc,
193 SV("%b='5月'\t%h='5月'\t%B='5月'\t%m='05'\t%Om='05'\n"),
194 lfmt,
195 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
196#elif defined(__APPLE__) // _WIN32
197 check(loc,
198 SV("%b=' 1'\t%h=' 1'\t%B='1月'\t%m='01'\t%Om='01'\n"),
199 lfmt,
200 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
201
202 check(loc,
203 SV("%b=' 5'\t%h=' 5'\t%B='5月'\t%m='05'\t%Om='05'\n"),
204 lfmt,
205 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
206#elif defined(__FreeBSD__) // _WIN32
207 check(loc,
208 SV("%b=' 1月'\t%h=' 1月'\t%B='1月'\t%m='01'\t%Om='01'\n"),
209 lfmt,
210 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
211
212 check(loc,
213 SV("%b=' 5月'\t%h=' 5月'\t%B='5月'\t%m='05'\t%Om='05'\n"),
214 lfmt,
215 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
216#else // _WIN32
217 check(loc,
218 SV("%b=' 1月'\t%h=' 1月'\t%B='1月'\t%m='01'\t%Om='一'\n"),
219 lfmt,
220 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
221
222 check(loc,
223 SV("%b=' 5月'\t%h=' 5月'\t%B='5月'\t%m='05'\t%Om='五'\n"),
224 lfmt,
225 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
226#endif // _WIN32
227
228 std::locale::global(loc: std::locale::classic());
229}
230
231template <class CharT>
232static void test_valid_values_day() {
233 using namespace std::literals::chrono_literals;
234
235 constexpr std::basic_string_view<CharT> fmt = SV("{:%%d='%d'%t%%Od='%Od'%t%%e='%e'%t%%Oe='%Oe'%n}");
236 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%d='%d'%t%%Od='%Od'%t%%e='%e'%t%%Oe='%Oe'%n}");
237
238 const std::locale loc(LOCALE_ja_JP_UTF_8);
239 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
240
241 // Non localized output using C-locale
242 check(SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), fmt,
243 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
244
245 check(SV("%d='13'\t%Od='13'\t%e='13'\t%Oe='13'\n"),
246 fmt,
247 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
248
249 // Use the global locale (fr_FR)
250 check(SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), lfmt,
251 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
252
253 check(SV("%d='13'\t%Od='13'\t%e='13'\t%Oe='13'\n"),
254 lfmt,
255 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
256
257 // Use supplied locale (ja_JP). This locale has a different alternate.
258#if defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
259 check(loc,
260 SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"),
261 lfmt,
262 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
263
264 check(loc,
265 SV("%d='13'\t%Od='13'\t%e='13'\t%Oe='13'\n"),
266 lfmt,
267 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
268#else // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
269 check(loc,
270 SV("%d='01'\t%Od='一'\t%e=' 1'\t%Oe='一'\n"),
271 lfmt,
272 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
273
274 check(loc,
275 SV("%d='13'\t%Od='十三'\t%e='13'\t%Oe='十三'\n"),
276 lfmt,
277 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
278
279#endif // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
280
281 std::locale::global(loc: std::locale::classic());
282}
283
284template <class CharT>
285static void test_valid_values_weekday() {
286 using namespace std::literals::chrono_literals;
287
288 constexpr std::basic_string_view<CharT> fmt =
289 SV("{:%%a='%a'%t%%A='%A'%t%%u='%u'%t%%Ou='%Ou'%t%%w='%w'%t%%Ow='%Ow'%n}");
290 constexpr std::basic_string_view<CharT> lfmt =
291 SV("{:L%%a='%a'%t%%A='%A'%t%%u='%u'%t%%Ou='%Ou'%t%%w='%w'%t%%Ow='%Ow'%n}");
292
293 const std::locale loc(LOCALE_ja_JP_UTF_8);
294 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
295
296 // Non localized output using C-locale
297 check(SV("%a='Thu'\t%A='Thursday'\t%u='4'\t%Ou='4'\t%w='4'\t%Ow='4'\n"),
298 fmt,
299 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
300
301 check(SV("%a='Sun'\t%A='Sunday'\t%u='7'\t%Ou='7'\t%w='0'\t%Ow='0'\n"),
302 fmt,
303 file_seconds(4'294'967'295s)); // 06:28:15 UTC on Sunday, 7 February 2106
304
305 // Use the global locale (fr_FR)
306#if defined(__APPLE__)
307 check(SV("%a='Jeu'\t%A='Jeudi'\t%u='4'\t%Ou='4'\t%w='4'\t%Ow='4'\n"),
308 lfmt,
309 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
310
311 check(SV("%a='Dim'\t%A='Dimanche'\t%u='7'\t%Ou='7'\t%w='0'\t%Ow='0'\n"),
312 lfmt,
313 file_seconds(4'294'967'295s)); // 06:28:15 UTC on Sunday, 7 February 2106
314#else
315 check(SV("%a='jeu.'\t%A='jeudi'\t%u='4'\t%Ou='4'\t%w='4'\t%Ow='4'\n"),
316 lfmt,
317 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
318
319 check(SV("%a='dim.'\t%A='dimanche'\t%u='7'\t%Ou='7'\t%w='0'\t%Ow='0'\n"),
320 lfmt,
321 file_seconds(4'294'967'295s)); // 06:28:15 UTC on Sunday, 7 February 2106
322#endif
323
324 // Use supplied locale (ja_JP).
325 // This locale has a different alternate, but not on all platforms
326#if defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
327 check(loc,
328 SV("%a='木'\t%A='木曜日'\t%u='4'\t%Ou='4'\t%w='4'\t%Ow='4'\n"),
329 lfmt,
330 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
331
332 check(loc,
333 SV("%a='日'\t%A='日曜日'\t%u='7'\t%Ou='7'\t%w='0'\t%Ow='0'\n"),
334 lfmt,
335 file_seconds(4'294'967'295s)); // 06:28:15 UTC on Sunday, 7 February 2106
336#else // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
337 check(loc,
338 SV("%a='木'\t%A='木曜日'\t%u='4'\t%Ou='四'\t%w='4'\t%Ow='四'\n"),
339 lfmt,
340 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
341
342 check(loc,
343 SV("%a='日'\t%A='日曜日'\t%u='7'\t%Ou='七'\t%w='0'\t%Ow='〇'\n"),
344 lfmt,
345 file_seconds(4'294'967'295s)); // 06:28:15 UTC on Sunday, 7 February 2106
346#endif // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
347
348 std::locale::global(loc: std::locale::classic());
349}
350
351template <class CharT>
352static void test_valid_values_day_of_year() {
353 using namespace std::literals::chrono_literals;
354
355 constexpr std::basic_string_view<CharT> fmt = SV("{:%%j='%j'%n}");
356 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%j='%j'%n}");
357
358 const std::locale loc(LOCALE_ja_JP_UTF_8);
359 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
360
361 // Non localized output using C-locale
362 check(SV("%j='001'\n"), fmt, file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
363 check(SV("%j='138'\n"), fmt, file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
364
365 // Use the global locale (fr_FR)
366 check(SV("%j='001'\n"), lfmt, file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
367 check(SV("%j='138'\n"), lfmt, file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
368
369 // Use supplied locale (ja_JP). This locale has a different alternate.
370 check(loc, SV("%j='001'\n"), lfmt, file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
371
372 check(loc, SV("%j='138'\n"), lfmt, file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
373
374 std::locale::global(loc: std::locale::classic());
375}
376
377template <class CharT>
378static void test_valid_values_week() {
379 using namespace std::literals::chrono_literals;
380
381 constexpr std::basic_string_view<CharT> fmt = SV("{:%%U='%U'%t%%OU='%OU'%t%%W='%W'%t%%OW='%OW'%n}");
382 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%U='%U'%t%%OU='%OU'%t%%W='%W'%t%%OW='%OW'%n}");
383
384 const std::locale loc(LOCALE_ja_JP_UTF_8);
385 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
386
387 // Non localized output using C-locale
388 check(SV("%U='00'\t%OU='00'\t%W='00'\t%OW='00'\n"), fmt,
389 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
390
391 check(SV("%U='20'\t%OU='20'\t%W='20'\t%OW='20'\n"),
392 fmt,
393 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
394
395 // Use the global locale (fr_FR)
396 check(SV("%U='00'\t%OU='00'\t%W='00'\t%OW='00'\n"), lfmt,
397 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
398
399 check(SV("%U='20'\t%OU='20'\t%W='20'\t%OW='20'\n"),
400 lfmt,
401 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
402
403 // Use supplied locale (ja_JP). This locale has a different alternate.
404#if defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
405 check(loc,
406 SV("%U='00'\t%OU='00'\t%W='00'\t%OW='00'\n"),
407 lfmt,
408 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
409
410 check(loc,
411 SV("%U='20'\t%OU='20'\t%W='20'\t%OW='20'\n"),
412 lfmt,
413 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
414#else // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
415 check(loc,
416 SV("%U='00'\t%OU='〇'\t%W='00'\t%OW='〇'\n"),
417 lfmt,
418 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
419
420 check(loc,
421 SV("%U='20'\t%OU='二十'\t%W='20'\t%OW='二十'\n"),
422 lfmt,
423 file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033
424#endif // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
425 std::locale::global(loc: std::locale::classic());
426}
427
428template <class CharT>
429static void test_valid_values_iso_8601_week() {
430 using namespace std::literals::chrono_literals;
431
432 constexpr std::basic_string_view<CharT> fmt = SV("{:%%g='%g'%t%%G='%G'%t%%V='%V'%t%%OV='%OV'%n}");
433 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%g='%g'%t%%G='%G'%t%%V='%V'%t%%OV='%OV'%n}");
434
435 const std::locale loc(LOCALE_ja_JP_UTF_8);
436 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
437
438 // Non localized output using C-locale
439 check(SV("%g='70'\t%G='1970'\t%V='01'\t%OV='01'\n"), fmt,
440 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
441
442 check(SV("%g='09'\t%G='2009'\t%V='07'\t%OV='07'\n"),
443 fmt,
444 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
445
446 // Use the global locale (fr_FR)
447 check(SV("%g='70'\t%G='1970'\t%V='01'\t%OV='01'\n"), lfmt,
448 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
449
450 check(SV("%g='09'\t%G='2009'\t%V='07'\t%OV='07'\n"),
451 lfmt,
452 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
453
454 // Use supplied locale (ja_JP). This locale has a different alternate.
455#if defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
456 check(loc,
457 SV("%g='70'\t%G='1970'\t%V='01'\t%OV='01'\n"),
458 lfmt,
459 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
460
461 check(loc,
462 SV("%g='09'\t%G='2009'\t%V='07'\t%OV='07'\n"),
463 lfmt,
464 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
465#else // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
466 check(loc,
467 SV("%g='70'\t%G='1970'\t%V='01'\t%OV='一'\n"),
468 lfmt,
469 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
470
471 check(loc,
472 SV("%g='09'\t%G='2009'\t%V='07'\t%OV='七'\n"),
473 lfmt,
474 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
475#endif // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
476
477 std::locale::global(loc: std::locale::classic());
478}
479
480template <class CharT>
481static void test_valid_values_date() {
482 using namespace std::literals::chrono_literals;
483
484 constexpr std::basic_string_view<CharT> fmt = SV("{:%%D='%D'%t%%F='%F'%t%%x='%x'%t%%Ex='%Ex'%n}");
485 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%D='%D'%t%%F='%F'%t%%x='%x'%t%%Ex='%Ex'%n}");
486
487 const std::locale loc(LOCALE_ja_JP_UTF_8);
488 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
489
490 // Non localized output using C-locale
491 check(SV("%D='01/01/70'\t%F='1970-01-01'\t%x='01/01/70'\t%Ex='01/01/70'\n"),
492 fmt,
493 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
494
495 check(SV("%D='02/13/09'\t%F='2009-02-13'\t%x='02/13/09'\t%Ex='02/13/09'\n"),
496 fmt,
497 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
498
499 // Use the global locale (fr_FR)
500#if defined(__APPLE__) || defined(__FreeBSD__)
501 check(SV("%D='01/01/70'\t%F='1970-01-01'\t%x='01.01.1970'\t%Ex='01.01.1970'\n"),
502 lfmt,
503 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
504
505 check(SV("%D='02/13/09'\t%F='2009-02-13'\t%x='13.02.2009'\t%Ex='13.02.2009'\n"),
506 lfmt,
507 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
508#else
509 check(SV("%D='01/01/70'\t%F='1970-01-01'\t%x='01/01/1970'\t%Ex='01/01/1970'\n"),
510 lfmt,
511 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
512
513 check(SV("%D='02/13/09'\t%F='2009-02-13'\t%x='13/02/2009'\t%Ex='13/02/2009'\n"),
514 lfmt,
515 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
516#endif
517
518 // Use supplied locale (ja_JP). This locale has a different alternate.
519#if defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
520 check(loc,
521 SV("%D='01/01/70'\t%F='1970-01-01'\t%x='1970/01/01'\t%Ex='1970/01/01'\n"),
522 lfmt,
523 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
524
525 check(loc,
526 SV("%D='02/13/09'\t%F='2009-02-13'\t%x='2009/02/13'\t%Ex='2009/02/13'\n"),
527 lfmt,
528 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
529#else // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
530 check(loc,
531 SV("%D='01/01/70'\t%F='1970-01-01'\t%x='1970年01月01日'\t%Ex='昭和45年01月01日'\n"),
532 lfmt,
533 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
534
535 check(loc,
536 SV("%D='02/13/09'\t%F='2009-02-13'\t%x='2009年02月13日'\t%Ex='平成21年02月13日'\n"),
537 lfmt,
538 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
539#endif // defined(_WIN32) || defined(__APPLE__) || defined(_AIX) || defined(__FreeBSD__)
540
541 std::locale::global(loc: std::locale::classic());
542}
543
544template <class CharT>
545static void test_valid_values_time() {
546 using namespace std::literals::chrono_literals;
547
548 constexpr std::basic_string_view<CharT> fmt = SV(
549 "{:"
550 "%%H='%H'%t"
551 "%%OH='%OH'%t"
552 "%%I='%I'%t"
553 "%%OI='%OI'%t"
554 "%%M='%M'%t"
555 "%%OM='%OM'%t"
556 "%%S='%S'%t"
557 "%%OS='%OS'%t"
558 "%%p='%p'%t"
559 "%%R='%R'%t"
560 "%%T='%T'%t"
561 "%%r='%r'%t"
562 "%%X='%X'%t"
563 "%%EX='%EX'%t"
564 "%n}");
565 constexpr std::basic_string_view<CharT> lfmt = SV(
566 "{:L"
567 "%%H='%H'%t"
568 "%%OH='%OH'%t"
569 "%%I='%I'%t"
570 "%%OI='%OI'%t"
571 "%%M='%M'%t"
572 "%%OM='%OM'%t"
573 "%%S='%S'%t"
574 "%%OS='%OS'%t"
575 "%%p='%p'%t"
576 "%%R='%R'%t"
577 "%%T='%T'%t"
578 "%%r='%r'%t"
579 "%%X='%X'%t"
580 "%%EX='%EX'%t"
581 "%n}");
582
583 const std::locale loc(LOCALE_ja_JP_UTF_8);
584 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
585
586 // Non localized output using C-locale
587 check(SV("%H='00'\t"
588 "%OH='00'\t"
589 "%I='12'\t"
590 "%OI='12'\t"
591 "%M='00'\t"
592 "%OM='00'\t"
593 "%S='00'\t"
594 "%OS='00'\t"
595 "%p='AM'\t"
596 "%R='00:00'\t"
597 "%T='00:00:00'\t"
598 "%r='12:00:00 AM'\t"
599 "%X='00:00:00'\t"
600 "%EX='00:00:00'\t"
601 "\n"),
602 fmt,
603 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
604
605 check(SV("%H='23'\t"
606 "%OH='23'\t"
607 "%I='11'\t"
608 "%OI='11'\t"
609 "%M='31'\t"
610 "%OM='31'\t"
611 "%S='30.123'\t"
612 "%OS='30.123'\t"
613 "%p='PM'\t"
614 "%R='23:31'\t"
615 "%T='23:31:30.123'\t"
616 "%r='11:31:30 PM'\t"
617 "%X='23:31:30'\t"
618 "%EX='23:31:30'\t"
619 "\n"),
620 fmt,
621 std::chrono::sys_time<std::chrono::milliseconds>(
622 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009
623 // Use the global locale (fr_FR)
624 check(SV("%H='00'\t"
625 "%OH='00'\t"
626 "%I='12'\t"
627 "%OI='12'\t"
628 "%M='00'\t"
629 "%OM='00'\t"
630 "%S='00'\t"
631 "%OS='00'\t"
632#if defined(_AIX)
633 "%p='AM'\t"
634#else
635 "%p=''\t"
636#endif
637 "%R='00:00'\t"
638 "%T='00:00:00'\t"
639#ifdef _WIN32
640 "%r='00:00:00'\t"
641#elif defined(_AIX)
642 "%r='12:00:00 AM'\t"
643#elif defined(__APPLE__) || defined(__FreeBSD__)
644 "%r=''\t"
645#else
646 "%r='12:00:00 '\t"
647#endif
648 "%X='00:00:00'\t"
649 "%EX='00:00:00'\t"
650 "\n"),
651 lfmt,
652 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
653
654 check(SV("%H='23'\t"
655 "%OH='23'\t"
656 "%I='11'\t"
657 "%OI='11'\t"
658 "%M='31'\t"
659 "%OM='31'\t"
660 "%S='30,123'\t"
661 "%OS='30,123'\t"
662#if defined(_AIX)
663 "%p='PM'\t"
664#else
665 "%p=''\t"
666#endif
667 "%R='23:31'\t"
668 "%T='23:31:30,123'\t"
669#ifdef _WIN32
670 "%r='23:31:30'\t"
671#elif defined(_AIX)
672 "%r='11:31:30 PM'\t"
673#elif defined(__APPLE__) || defined(__FreeBSD__)
674 "%r=''\t"
675#elif defined(_WIN32)
676 "%r='23:31:30 '\t"
677#else
678 "%r='11:31:30 '\t"
679#endif
680 "%X='23:31:30'\t"
681 "%EX='23:31:30'\t"
682 "\n"),
683 lfmt,
684 std::chrono::sys_time<std::chrono::milliseconds>(
685 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009
686
687 // Use supplied locale (ja_JP). This locale has a different alternate.a
688#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) || defined(__FreeBSD__)
689 check(loc,
690 SV("%H='00'\t"
691 "%OH='00'\t"
692 "%I='12'\t"
693 "%OI='12'\t"
694 "%M='00'\t"
695 "%OM='00'\t"
696 "%S='00'\t"
697 "%OS='00'\t"
698# if defined(__APPLE__)
699 "%p='AM'\t"
700# else
701 "%p='午前'\t"
702# endif
703 "%R='00:00'\t"
704 "%T='00:00:00'\t"
705# if defined(__APPLE__) || defined(__FreeBSD__)
706# if defined(__APPLE__)
707 "%r='12:00:00 AM'\t"
708# else
709 "%r='12:00:00 午前'\t"
710# endif
711 "%X='00時00分00秒'\t"
712 "%EX='00時00分00秒'\t"
713# elif defined(_WIN32)
714 "%r='0:00:00'\t"
715 "%X='0:00:00'\t"
716 "%EX='0:00:00'\t"
717# else
718 "%r='午前12:00:00'\t"
719 "%X='00:00:00'\t"
720 "%EX='00:00:00'\t"
721# endif
722 "\n"),
723 lfmt,
724 std::chrono::hh_mm_ss(0s));
725
726 check(loc,
727 SV("%H='23'\t"
728 "%OH='23'\t"
729 "%I='11'\t"
730 "%OI='11'\t"
731 "%M='31'\t"
732 "%OM='31'\t"
733 "%S='30.123'\t"
734 "%OS='30.123'\t"
735# if defined(__APPLE__)
736 "%p='PM'\t"
737# else
738 "%p='午後'\t"
739# endif
740 "%R='23:31'\t"
741 "%T='23:31:30.123'\t"
742# if defined(__APPLE__) || defined(__FreeBSD__)
743# if defined(__APPLE__)
744 "%r='11:31:30 PM'\t"
745# else
746 "%r='11:31:30 午後'\t"
747# endif
748 "%X='23時31分30秒'\t"
749 "%EX='23時31分30秒'\t"
750# elif defined(_WIN32)
751 "%r='23:31:30'\t"
752 "%X='23:31:30'\t"
753 "%EX='23:31:30'\t"
754# else
755 "%r='午後11:31:30'\t"
756 "%X='23:31:30'\t"
757 "%EX='23:31:30'\t"
758# endif
759 "\n"),
760 lfmt,
761 std::chrono::hh_mm_ss(23h + 31min + 30s + 123ms));
762#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) || defined(__FreeBSD__)
763 check(loc,
764 SV("%H='00'\t"
765 "%OH='〇'\t"
766 "%I='12'\t"
767 "%OI='十二'\t"
768 "%M='00'\t"
769 "%OM='〇'\t"
770 "%S='00'\t"
771 "%OS='〇'\t"
772 "%p='午前'\t"
773 "%R='00:00'\t"
774 "%T='00:00:00'\t"
775 "%r='午前12時00分00秒'\t"
776 "%X='00時00分00秒'\t"
777 "%EX='00時00分00秒'\t"
778 "\n"),
779 lfmt,
780 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
781
782 check(loc,
783 SV("%H='23'\t"
784 "%OH='二十三'\t"
785 "%I='11'\t"
786 "%OI='十一'\t"
787 "%M='31'\t"
788 "%OM='三十一'\t"
789 "%S='30.123'\t"
790 "%OS='三十.123'\t"
791 "%p='午後'\t"
792 "%R='23:31'\t"
793 "%T='23:31:30.123'\t"
794 "%r='午後11時31分30秒'\t"
795 "%X='23時31分30秒'\t"
796 "%EX='23時31分30秒'\t"
797 "\n"),
798 lfmt,
799 std::chrono::sys_time<std::chrono::milliseconds>(
800 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009
801#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) || defined(__FreeBSD__)
802
803 std::locale::global(loc: std::locale::classic());
804}
805
806template <class CharT>
807static void test_valid_values_date_time() {
808 using namespace std::literals::chrono_literals;
809
810 constexpr std::basic_string_view<CharT> fmt = SV("{:%%c='%c'%t%%Ec='%Ec'%n}");
811 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%c='%c'%t%%Ec='%Ec'%n}");
812
813 const std::locale loc(LOCALE_ja_JP_UTF_8);
814 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
815
816 // Non localized output using C-locale
817 check(SV("%c='Thu Jan 1 00:00:00 1970'\t%Ec='Thu Jan 1 00:00:00 1970'\n"),
818 fmt,
819 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
820
821 check(SV("%c='Fri Feb 13 23:31:30 2009'\t%Ec='Fri Feb 13 23:31:30 2009'\n"),
822 fmt,
823 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
824
825 // Use the global locale (fr_FR)
826 check(
827// https://sourceware.org/bugzilla/show_bug.cgi?id=24054
828#if defined(__powerpc__) && defined(__linux__)
829 SV("%c='jeu. 01 janv. 1970 00:00:00 UTC'\t%Ec='jeu. 01 janv. 1970 00:00:00 UTC'\n"),
830#elif defined(__GLIBC__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 29
831 SV("%c='jeu. 01 janv. 1970 00:00:00 GMT'\t%Ec='jeu. 01 janv. 1970 00:00:00 GMT'\n"),
832#elif defined(_AIX)
833 SV("%c=' 1 janvier 1970 à 00:00:00 UTC'\t%Ec=' 1 janvier 1970 à 00:00:00 UTC'\n"),
834#elif defined(__APPLE__)
835 SV("%c='Jeu 1 jan 00:00:00 1970'\t%Ec='Jeu 1 jan 00:00:00 1970'\n"),
836#elif defined(_WIN32)
837 SV("%c='01/01/1970 00:00:00'\t%Ec='01/01/1970 00:00:00'\n"),
838#elif defined(__FreeBSD__)
839 SV("%c='jeu. 1 janv. 00:00:00 1970'\t%Ec='jeu. 1 janv. 00:00:00 1970'\n"),
840#else
841 SV("%c='jeu. 01 janv. 1970 00:00:00'\t%Ec='jeu. 01 janv. 1970 00:00:00'\n"),
842#endif
843 lfmt,
844 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
845
846 check(
847// https://sourceware.org/bugzilla/show_bug.cgi?id=24054
848#if defined(__powerpc__) && defined(__linux__)
849 SV("%c='ven. 13 févr. 2009 23:31:30 UTC'\t%Ec='ven. 13 févr. 2009 23:31:30 UTC'\n"),
850#elif defined(__GLIBC__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 29
851 SV("%c='ven. 13 févr. 2009 23:31:30 GMT'\t%Ec='ven. 13 févr. 2009 23:31:30 GMT'\n"),
852#elif defined(_AIX)
853 SV("%c='13 février 2009 à 23:31:30 UTC'\t%Ec='13 février 2009 à 23:31:30 UTC'\n"),
854#elif defined(__APPLE__)
855 SV("%c='Ven 13 fév 23:31:30 2009'\t%Ec='Ven 13 fév 23:31:30 2009'\n"),
856#elif defined(_WIN32)
857 SV("%c='13/02/2009 23:31:30'\t%Ec='13/02/2009 23:31:30'\n"),
858#elif defined(__FreeBSD__)
859 SV("%c='ven. 13 févr. 23:31:30 2009'\t%Ec='ven. 13 févr. 23:31:30 2009'\n"),
860#else
861 SV("%c='ven. 13 févr. 2009 23:31:30'\t%Ec='ven. 13 févr. 2009 23:31:30'\n"),
862#endif
863 lfmt,
864 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
865
866 // Use supplied locale (ja_JP). This locale has a different alternate.a
867#if defined(__APPLE__) || defined(__FreeBSD__)
868 check(loc,
869 SV("%c='木 1/ 1 00:00:00 1970'\t%Ec='木 1/ 1 00:00:00 1970'\n"),
870 lfmt,
871 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
872 check(loc,
873 SV("%c='金 2/13 23:31:30 2009'\t%Ec='金 2/13 23:31:30 2009'\n"),
874 lfmt,
875 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
876#elif defined(_AIX) // defined(__APPLE__)|| defined(__FreeBSD__)
877 check(loc,
878 SV("%c='1970年01月 1日 00:00:00 UTC'\t%Ec='1970年01月 1日 00:00:00 UTC'\n"),
879 lfmt,
880 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
881 check(loc,
882 SV("%c='2009年02月13日 23:31:30 UTC'\t%Ec='2009年02月13日 23:31:30 UTC'\n"),
883 lfmt,
884 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
885#elif defined(_WIN32) // defined(__APPLE__)|| defined(__FreeBSD__)
886 check(loc,
887 SV("%c='1970/01/01 0:00:00'\t%Ec='1970/01/01 0:00:00'\n"),
888 lfmt,
889 std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
890 check(loc,
891 SV("%c='2009/02/13 23:31:30'\t%Ec='2009/02/13 23:31:30'\n"),
892 lfmt,
893 std::chrono::sys_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
894#else // defined(__APPLE__)|| defined(__FreeBSD__)
895 check(loc,
896 SV("%c='1970年01月01日 00時00分00秒'\t%Ec='昭和45年01月01日 00時00分00秒'\n"),
897 lfmt,
898 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
899
900 check(loc,
901 SV("%c='2009年02月13日 23時31分30秒'\t%Ec='平成21年02月13日 23時31分30秒'\n"),
902 lfmt,
903 file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009
904#endif // defined(__APPLE__)|| defined(__FreeBSD__)
905
906 std::locale::global(loc: std::locale::classic());
907}
908
909template <class CharT>
910static void test_valid_values_time_zone() {
911 using namespace std::literals::chrono_literals;
912
913 constexpr std::basic_string_view<CharT> fmt = SV("{:%%z='%z'%t%%Ez='%Ez'%t%%Oz='%Oz'%t%%Z='%Z'%n}");
914 constexpr std::basic_string_view<CharT> lfmt = SV("{:L%%z='%z'%t%%Ez='%Ez'%t%%Oz='%Oz'%t%%Z='%Z'%n}");
915
916 const std::locale loc(LOCALE_ja_JP_UTF_8);
917 std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
918
919 // Non localized output using C-locale
920 check(SV("%z='+0000'\t%Ez='+00:00'\t%Oz='+00:00'\t%Z='UTC'\n"),
921 fmt,
922 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
923
924 // Use the global locale (fr_FR)
925 check(SV("%z='+0000'\t%Ez='+00:00'\t%Oz='+00:00'\t%Z='UTC'\n"),
926 lfmt,
927 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
928
929 // Use supplied locale (ja_JP).
930 check(loc,
931 SV("%z='+0000'\t%Ez='+00:00'\t%Oz='+00:00'\t%Z='UTC'\n"),
932 lfmt,
933 file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970
934
935 std::locale::global(loc: std::locale::classic());
936}
937
938template <class CharT>
939static void test_valid_values() {
940 test_valid_values_year<CharT>();
941 test_valid_values_month<CharT>();
942 test_valid_values_day<CharT>();
943 test_valid_values_weekday<CharT>();
944 test_valid_values_day_of_year<CharT>();
945 test_valid_values_week<CharT>();
946 test_valid_values_iso_8601_week<CharT>();
947 test_valid_values_date<CharT>();
948 test_valid_values_time<CharT>();
949 test_valid_values_date_time<CharT>();
950 test_valid_values_time_zone<CharT>();
951}
952
953template <class CharT>
954static void test() {
955 using namespace std::literals::chrono_literals;
956
957 test_no_chrono_specs<CharT>();
958 test_valid_values<CharT>();
959
960 check_invalid_types<CharT>(
961 {SV("a"), SV("A"), SV("b"), SV("B"), SV("c"), SV("C"), SV("d"), SV("D"), SV("e"), SV("F"), SV("g"),
962 SV("G"), SV("h"), SV("H"), SV("I"), SV("j"), SV("m"), SV("M"), SV("p"), SV("r"), SV("R"), SV("S"),
963 SV("T"), SV("u"), SV("U"), SV("V"), SV("w"), SV("W"), SV("x"), SV("X"), SV("y"), SV("Y"), SV("z"),
964 SV("Z"), SV("Ec"), SV("EC"), SV("Ex"), SV("EX"), SV("Ey"), SV("EY"), SV("Ez"), SV("Od"), SV("Oe"), SV("OH"),
965 SV("OI"), SV("Om"), SV("OM"), SV("OS"), SV("Ou"), SV("OU"), SV("OV"), SV("Ow"), SV("OW"), SV("Oy"), SV("Oz")},
966 file_seconds(0s));
967
968 check_exception("The format specifier expects a '%' or a '}'", SV("{:A"), file_seconds(0s));
969 check_exception("The chrono specifiers contain a '{'", SV("{:%%{"), file_seconds(0s));
970 check_exception("End of input while parsing a conversion specifier", SV("{:%"), file_seconds(0s));
971 check_exception("End of input while parsing the modifier E", SV("{:%E"), file_seconds(0s));
972 check_exception("End of input while parsing the modifier O", SV("{:%O"), file_seconds(0s));
973
974 // Precision not allowed
975 check_exception("The format specifier expects a '%' or a '}'", SV("{:.3}"), file_seconds(0s));
976}
977
978int main(int, char**) {
979 test<char>();
980
981#ifndef TEST_HAS_NO_WIDE_CHARACTERS
982 test<wchar_t>();
983#endif
984
985 return 0;
986}
987

source code of libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp