]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/date_time/test/gregorian/testdate_input_facet.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / date_time / test / gregorian / testdate_input_facet.cpp
CommitLineData
7c673cae
FG
1/* Copyright (c) 2005 CrystalClear Software, Inc.
2 * Use, modification and distribution is subject to the
3 * Boost Software License, Version 1.0. (See accompanying
4 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
5 * Author: Jeff Garland, Bart Garst
6 * $Date$
7 */
8
9#include "boost/date_time/gregorian/gregorian.hpp"
10#include "../testfrmwk.hpp"
11#include <iostream>
12#include <sstream>
13#include <string>
14#include <vector>
15
16#ifndef USE_DATE_TIME_PRE_1_33_FACET_IO
17// for tests that are expected to fail and throw exceptions
18template<class temporal_type, class exception_type>
19bool failure_test(temporal_type component,
20 const std::string& input,
21 exception_type const& /*except*/,
22 boost::gregorian::date_input_facet* facet)
23{
24 using namespace boost::gregorian;
25 bool result = false;
26 std::istringstream iss(input);
27 iss.exceptions(std::ios_base::failbit); // turn on exceptions
28 iss.imbue(std::locale(std::locale::classic(), facet));
29 try {
30 iss >> component;
31 }
32 catch(exception_type& e) {
33 std::cout << "Expected exception caught: \""
34 << e.what() << "\"" << std::endl;
35 result = iss.fail(); // failbit must be set to pass test
36 }
37 catch(...) {
38 result = false;
39 }
40
41 return result;
42}
43
44// for tests that are expected to fail quietly
45template<class temporal_type>
46bool failure_test(temporal_type component,
47 const std::string& input,
48 boost::gregorian::date_input_facet* facet)
49{
50 using namespace boost::gregorian;
51 std::istringstream iss(input);
52 /* leave exceptions turned off
53 * iss.exceptions(std::ios_base::failbit); */
54 iss.imbue(std::locale(std::locale::classic(), facet));
55 try {
56 iss >> component;
57 }
58 catch(...) {
59 std::cout << "Caught unexpected exception" << std::endl;
60 return false;
61 }
62
63 return iss.fail(); // failbit must be set to pass test
64}
65
66#endif
67
68
69
70int main(){
71#ifndef USE_DATE_TIME_PRE_1_33_FACET_IO
72 using namespace boost::gregorian;
73
74 {
75 // verify no extra character are consumed
76 greg_month m(1);
77 std::stringstream ss("Mar.");
78 std::istreambuf_iterator<char> sitr(ss), str_end;
79
92f5a8d4
TL
80 date_input_facet f;
81 f.get(sitr, str_end, ss, m);
7c673cae
FG
82 check("No extra characters consumed", m == greg_month(Mar) && *sitr == '.');
83 }
84
85 // set up initial objects
86 date d(not_a_date_time);
87 days dd(not_a_date_time);
88 greg_month m(1);
89 greg_weekday gw(0);
90 greg_day gd(1);
91 greg_year gy(2000);
92 // exceptions for failure_tests
93 std::ios_base::failure e_failure("default");
94 bad_month e_bad_month;
95 bad_year e_bad_year;
96 bad_day_of_month e_bad_day_of_month;
97 bad_weekday e_bad_weekday;
98 bad_day_of_year e_bad_day_of_year;
99
100 // default format tests: date, days, month, weekday, day, year
101 std::istringstream iss("2005-Jan-15 21 Feb Tue 4 2002");
102 iss >> d;
103 check_equal("Default format date", d, date(2005,Jan,15));
104 iss >> dd;
105 check_equal("Default (only) format positive days", dd, days(21));
106 iss >> m;
107 check_equal("Default format month", m, greg_month(2));
108 iss >> gw;
109 check_equal("Default format weekday", gw, greg_weekday(2));
110 iss >> gd;
111 check_equal("Default (only) format day of month", gd, greg_day(4));
112 iss >> gy;
113 check_equal("Default format year", gy, greg_year(2002));
114 // failure tests
115 check("Input Misspelled in year (date) w/exceptions",
116 failure_test(d, "205-Jan-15", e_bad_year, new date_input_facet()));
117 check("Input Misspelled in year (date) no-exceptions",
118 failure_test(d, "205-Jan-15", new date_input_facet()));
119 check("Input Misspelled in month (date) w/exceptions",
120 failure_test(d, "2005-Jsn-15", e_bad_month, new date_input_facet()));
121 check("Input Misspelled in month (date) no-exceptions",
122 failure_test(d, "2005-Jsn-15", new date_input_facet()));
123 check("Input Misspelled in day (date) w/exceptions",
124 failure_test(d, "2005-Jan-51", e_bad_day_of_month, new date_input_facet()));
125 check("Input Misspelled in day (date) no-exceptions",
126 failure_test(d, "2005-Jan-51", new date_input_facet()));
127 check("Input Misspelled greg_weekday w/exceptions",
128 failure_test(gw, "San", e_bad_weekday, new date_input_facet()));
129 check("Input Misspelled greg_weekday no-exceptions",
130 failure_test(gw, "San", new date_input_facet()));
131 check("Input Misspelled month w/exceptions",
132 failure_test(m, "Jsn", e_bad_month, new date_input_facet()));
133 check("Input Misspelled month no-exceptions",
134 failure_test(m, "Jsn", new date_input_facet()));
135 check("Bad Input greg_day w/exceptions",
136 failure_test(gd, "Sun", e_bad_day_of_month, new date_input_facet()));
137 check("Bad Input greg_day no-exceptions",
138 failure_test(gd, "Sun", new date_input_facet()));
139 check("Input Misspelled greg_year w/exceptions",
140 failure_test(gy, "205", e_bad_year, new date_input_facet()));
141 check("Input Misspelled greg_year no-exceptions",
142 failure_test(gy, "205", new date_input_facet()));
143
144 // change to full length names, iso date format, and 2 digit year
145 date_input_facet* facet = new date_input_facet();
146 facet->set_iso_format();
147 facet->month_format("%B");
148 facet->weekday_format("%A");
149 facet->year_format("%y");
150 iss.str("20050115 -55 February Tuesday 02");
151 iss.imbue(std::locale(std::locale::classic(), facet));
152
153 iss >> d;
154 check_equal("ISO format date", d, date(2005,Jan,15));
155 iss >> dd;
156 check_equal("Default (only) format negative days", dd, days(-55));
157 iss >> m;
158 check_equal("Full format month", m, greg_month(2));
159 iss >> gw;
160 check_equal("Full format weekday", gw, greg_weekday(2));
161 iss >> gy;
162 check_equal("2 digit format year", gy, greg_year(2002));
163
164 date_input_facet* f1 = new date_input_facet();
165 date_input_facet* f2 = new date_input_facet();
166 f1->set_iso_format();
167 f2->set_iso_format();
168 check("Missing digit(s) in ISO string", failure_test(d,"2005071", f1));
169 check("Missing digit(s) in ISO string",
170 failure_test(d,"2005071", e_bad_day_of_month, f2));
171
172 { // literal % in format tests
11fdf7f2
TL
173 date dx(not_a_date_time);
174 greg_month mx(1);
175 greg_weekday gwx(0);
7c673cae
FG
176 greg_year y(1400);
177 date_input_facet* f = new date_input_facet("%%d %Y-%b-%d");
178 std::stringstream ss;
179 ss.imbue(std::locale(ss.getloc(), f));
180
181 ss.str("%d 2005-Jun-14");
11fdf7f2
TL
182 ss >> dx;
183 check_equal("Literal '%' in date format", dx, date(2005,Jun,14));
7c673cae
FG
184 f->format("%%%d %Y-%b-%d");
185 ss.str("%14 2005-Jun-14");
11fdf7f2
TL
186 ss >> dx;
187 check_equal("Multiple literal '%'s in date format", dx, date(2005,Jun,14));
7c673cae
FG
188
189 f->month_format("%%b %b");
190 ss.str("%b Jun");
11fdf7f2
TL
191 ss >> mx;
192 check_equal("Literal '%' in month format", mx, greg_month(6));
7c673cae
FG
193 f->month_format("%%%b");
194 ss.str("%Jun");
11fdf7f2
TL
195 ss >> mx;
196 check_equal("Multiple literal '%'s in month format", mx, greg_month(6));
7c673cae
FG
197
198 f->weekday_format("%%a %a");
199 ss.str("%a Tue");
11fdf7f2
TL
200 ss >> gwx;
201 check_equal("Literal '%' in weekday format", gwx, greg_weekday(2));
7c673cae
FG
202 f->weekday_format("%%%a");
203 ss.str("%Tue");
11fdf7f2
TL
204 ss >> gwx;
205 check_equal("Multiple literal '%'s in weekday format", gwx, greg_weekday(2));
7c673cae
FG
206
207 f->year_format("%%Y %Y");
208 ss.str("%Y 2005");
209 ss >> y;
210 check_equal("Literal '%' in year format", y, greg_year(2005));
211 f->year_format("%%%Y");
212 ss.str("%2005");
213 ss >> y;
214 check_equal("Multiple literal '%'s in year format", y, greg_year(2005));
215
216 f->year_format("%Y%");
217 ss.str("2005%");
218 ss >> y;
219 check_equal("Trailing'%'s in year format", y, greg_year(2005));
220 }
221
222 // All days, month, weekday, day, and year formats have been tested
223 // begin testing other date formats
224 facet->set_iso_extended_format();
225 iss.str("2005-01-15");
226 iss >> d;
227 check_equal("ISO Extended format date", d, date(2005,Jan,15));
228
229 facet->format("%B %d, %Y");
230 iss.str("March 15, 2006");
231 iss >> d;
232 check_equal("Custom date format: \"%B %d, %Y\" => 'March 15, 2006'",
233 d, date(2006,Mar,15));
234
235 facet->format("%Y-%j"); // Ordinal format ISO8601(2000 sect 5.2.2.1 extended)
236 iss.str("2006-074");
237 iss >> d;
238 check_equal("Custom date format: \"%Y-%j\" => '2006-074'",
239 d, date(2006,Mar,15));
240 check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (w/exceptions)",
241 failure_test(d, "2006-74", e_bad_day_of_year, facet));
242 check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (no exceptions)",
243 failure_test(d, "2006-74", facet));
244
245 // date_period tests
246
247 // A date_period is constructed with an open range. So the periods
248 // [2000-07--04/2000-07-25) <-- open range
249 // And
250 // [2000-07--04/2000-07-24] <-- closed range
251 // Are equal
252 date begin(2002, Jul, 4);
253 days len(21);
254 date_period dp(date(2000,Jan,1), days(1));
255 iss.str("[2002-07-04/2002-07-24]");
256 facet->set_iso_extended_format();
257 iss >> dp;
258 check_equal("Default period (closed range)", dp, date_period(begin,len));
259 {
260 std::stringstream ss;
11fdf7f2 261 date dx(not_a_date_time);
7c673cae
FG
262 date d2 = day_clock::local_day();
263 date d3(neg_infin);
264 date d4(pos_infin);
11fdf7f2
TL
265 date_period dpx(d2, dx); // date/nadt
266 date_period dp2(dx, dx); // nadt/nadt
7c673cae 267 date_period dp3(d3, d4);
11fdf7f2 268 ss << dpx;
7c673cae 269 ss >> dp2;
11fdf7f2 270 check_equal("Special values period (reversibility test)", dpx, dp2);
7c673cae
FG
271 ss.str("[-infinity/+infinity]");
272 ss >> dp2;
273 check_equal("Special values period (infinities)", dp3, dp2);
274 }
275
276
277 // open range
278 period_parser pp(period_parser::AS_OPEN_RANGE);
279 iss.str("[2002-07-04/2002-07-25)");
280 facet->period_parser(pp);
281 iss >> dp;
282 check_equal("Open range period", dp, date_period(begin,len));
283 // custom period delimiters
284 pp.delimiter_strings(" to ", "from ", " exclusive", " inclusive");
285 iss.str("from 2002-07-04 to 2002-07-25 exclusive");
286 facet->period_parser(pp);
287 iss >> dp;
288 check_equal("Open range period - custom delimiters", dp, date_period(begin,len));
289 pp.range_option(period_parser::AS_CLOSED_RANGE);
290 iss.str("from 2002-07-04 to 2002-07-24 inclusive");
291 facet->period_parser(pp);
292 iss >> dp;
293 check_equal("Closed range period - custom delimiters", dp, date_period(begin,len));
294
295
296 // date_generator tests
297
298 // date_generators use formats contained in the
299 // date_input_facet for weekdays and months
300 // reset month & weekday formats to defaults
301 facet->month_format("%b");
302 facet->weekday_format("%a");
303
304 partial_date pd(1,Jan);
305 nth_kday_of_month nkd(nth_kday_of_month::first, Sunday, Jan);
306 first_kday_of_month fkd(Sunday, Jan);
307 last_kday_of_month lkd(Sunday, Jan);
308 first_kday_before fkb(Sunday);
309 first_kday_after fka(Sunday);
310 // using default date_generator_parser "nth_strings"
311 iss.str("29 Feb");
312 iss >> pd;
313 // Feb-29 is a valid date_generator, get_date() will fail in a non-leap year
314 check_equal("Default strings, partial_date",
315 pd.get_date(2004), date(2004,Feb,29));
316 iss.str("second Mon of Mar");
317 iss >> nkd;
318 check_equal("Default strings, nth_day_of_the_week_in_month",
319 nkd.get_date(2004), date(2004,Mar,8));
320 iss.str("first Tue of Apr");
321 iss >> fkd;
322 check_equal("Default strings, first_day_of_the_week_in_month",
323 fkd.get_date(2004), date(2004,Apr,6));
324 iss.str("last Wed of May");
325 iss >> lkd;
326 check_equal("Default strings, last_day_of_the_week_in_month",
327 lkd.get_date(2004), date(2004,May,26));
328 iss.str("Thu before");
329 iss >> fkb;
330 check_equal("Default strings, first_day_of_the_week_before",
331 fkb.get_date(date(2004,Feb,8)), date(2004,Feb,5));
332 iss.str("Fri after");
333 iss >> fka;
334 check_equal("Default strings, first_day_of_the_week_after",
335 fka.get_date(date(2004,Feb,1)), date(2004,Feb,6));
336 // failure tests
337 check("Incorrect elements (date_generator) w/exceptions", // after/before type mixup
338 failure_test(fkb, "Fri after", e_failure, new date_input_facet()));
339 check("Incorrect elements (date_generator) no exceptions", // after/before type mixup
340 failure_test(fkb, "Fri after", new date_input_facet()));
341 check("Incorrect elements (date_generator) w/exceptions", // first/last type mixup
342 failure_test(lkd, "first Tue of Apr", e_failure, new date_input_facet()));
343 check("Incorrect elements (date_generator) no exceptions", // first/last type mixup
344 failure_test(lkd, "first Tue of Apr", new date_input_facet()));
345 check("Incorrect elements (date_generator) w/exceptions", // 'in' is wrong
346 failure_test(nkd, "second Mon in Mar", e_failure, new date_input_facet()));
347 check("Incorrect elements (date_generator) no exceptions", // 'in' is wrong
348 failure_test(nkd, "second Mon in Mar", new date_input_facet()));
349
350 // date_generators - custom element strings
351 facet->date_gen_element_strings("1st","2nd","3rd","4th","5th","final","prior to","past","in");
352 iss.str("3rd Sat in Jul");
353 iss >> nkd;
354 check_equal("Custom strings, nth_day_of_the_week_in_month",
355 nkd.get_date(2004), date(2004,Jul,17));
356 iss.str("1st Wed in May");
357 iss >> fkd;
358 check_equal("Custom strings, first_day_of_the_week_in_month",
359 fkd.get_date(2004), date(2004,May,5));
360 iss.str("final Tue in Apr");
361 iss >> lkd;
362 check_equal("Custom strings, last_day_of_the_week_in_month",
363 lkd.get_date(2004), date(2004,Apr,27));
364 iss.str("Fri prior to");
365 iss >> fkb;
366 check_equal("Custom strings, first_day_of_the_week_before",
367 fkb.get_date(date(2004,Feb,8)), date(2004,Feb,6));
368 iss.str("Thu past");
369 iss >> fka;
370 check_equal("Custom strings, first_day_of_the_week_after",
371 fka.get_date(date(2004,Feb,1)), date(2004,Feb,5));
372
373 // date_generators - special case with empty element string
374 /* Doesn't work. Empty string returns -1 from string_parse_tree
375 * because it attempts to match the next set of characters in the
376 * stream to the wrong element. Ex. It attempts to match "Mar" to
377 * the 'of' element in the test below.
378 *
379 facet->date_gen_element_strings("1st","2nd","3rd","4th","5th","final","prior to","past",""); // the 'of' string is an empty string
380 iss.str("final Mon Mar");
381 iss >> lkd;
382 check_equal("Special case, empty element string",
383 lkd.get_date(2005), date(2005,Mar,28));
384 */
385
386
387 // special values tests (date and days only)
388 iss.str("minimum-date-time +infinity");
389 iss >> d;
390 iss >> dd;
391 check_equal("Special values, default strings, min_date_time date",
392 d, date(min_date_time));
393 check_equal("Special values, default strings, pos_infin days",
394 dd, days(pos_infin));
395 iss.str("-infinity maximum-date-time");
396 iss >> d;
397 iss >> dd;
398 check_equal("Special values, default strings, neg_infin date",
399 d, date(neg_infin));
400 check_equal("Special values, default strings, max_date_time days",
401 dd, days(max_date_time));
402 iss.str("not-a-date-time");
403 iss >> d;
404 check_equal("Special values, default strings, not_a_date_time date",
405 d, date(not_a_date_time));
406
407 // in addition check that special_value_from_string also works correctly for other special values
408 check_equal("Special values, default strings, not_special test",
409 special_value_from_string("not_special"), not_special);
410 check_equal("Special values, default strings, junk test",
411 special_value_from_string("junk"), not_special);
412
413 // special values custom, strings
414 special_values_parser svp("NADT", "MINF", "INF", "MINDT", "MAXDT");
415 facet->special_values_parser(svp);
416 iss.str("MINDT INF");
417 iss >> d;
418 iss >> dd;
419 check_equal("Special values, custom strings, min_date_time date",
420 d, date(min_date_time));
421 check_equal("Special values, custom strings, pos_infin days",
422 dd, days(pos_infin));
423 iss.str("MINF MAXDT");
424 iss >> d;
425 iss >> dd;
426 check_equal("Special values, custom strings, neg_infin date",
427 d, date(neg_infin));
428 check_equal("Special values, custom strings, max_date_time days",
429 dd, days(max_date_time));
430 iss.str("NADT");
431 iss >> dd;
432 check_equal("Special values, custom strings, not_a_date_time days",
433 dd, days(not_a_date_time));
434 // failure test
435 check("Misspelled input, special_value date w/exceptions",
436 failure_test(d, "NSDT", e_bad_year, new date_input_facet()));
437 check("Misspelled input, special_value date no exceptions",
438 failure_test(d, "NSDT", new date_input_facet()));
439 check("Misspelled input, special_value days w/exceptions",
440 failure_test(dd, "NSDT", e_failure, new date_input_facet()));
441 check("Misspelled input, special_value days no exceptions",
442 failure_test(dd, "NSDT", new date_input_facet()));
443
444 {
445 // German names. Please excuse any errors, I don't speak German and
446 // had to rely on an on-line translation service.
447 // These tests check one of each (at least) from all sets of custom strings
448
449 // create a custom format_date_parser
450 std::string m_a[] = {"Jan","Feb","Mar","Apr","Mai",
451 "Jun","Jul","Aug","Sep","Okt","Nov","Dez"};
452 std::string m_f[] = {"Januar","Februar","Marz","April",
453 "Mai","Juni","Juli","August",
454 "September","Oktober","November","Dezember"};
455 std::string w_a[] = {"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"};
456 std::string w_f[] = {"Sonntag", "Montag", "Dienstag","Mittwoch",
457 "Donnerstag", "Freitag", "Samstag"};
458 typedef boost::date_time::format_date_parser<date, char> date_parser;
459 date_parser::input_collection_type months_abbrev;
460 date_parser::input_collection_type months_full;
461 date_parser::input_collection_type wkdays_abbrev;
462 date_parser::input_collection_type wkdays_full;
463 months_abbrev.assign(m_a, m_a+12);
464 months_full.assign(m_f, m_f+12);
465 wkdays_abbrev.assign(w_a, w_a+7);
466 wkdays_full.assign(w_f, w_f+7);
467 date_parser d_parser("%B %d %Y",
468 months_abbrev, months_full,
469 wkdays_abbrev, wkdays_full);
470
471 // create a special_values parser
472 special_values_parser sv_parser("NichtDatumzeit",
473 "Negativ Unendlichkeit",
474 "Positiv Unendlichkeit",
475 "Wenigstes Datum",
476 "Maximales Datum");
477
478 // create a period_parser
479 period_parser p_parser; // default will do
480 // create date_generator_parser
481 typedef boost::date_time::date_generator_parser<date,char> date_gen_parser;
482 date_gen_parser dg_parser("Zuerst","Zweitens","Dritt","Viert",
b32b8144 483 "F\xC3\xBCnft","Letzt","Vor","Nach","Von");
7c673cae
FG
484
485 // create the date_input_facet
486 date_input_facet* de_facet =
487 new date_input_facet("%B %d %Y",
488 d_parser,
489 sv_parser,
490 p_parser,
491 dg_parser);
11fdf7f2
TL
492 std::istringstream iss2;
493 iss2.imbue(std::locale(std::locale::classic(), de_facet));
7c673cae 494 // June 06 2005, Dec, minimum date, Tues
11fdf7f2
TL
495 iss2.str("Juni 06 2005 Dez Wenigstes Datum Die");
496 iss2 >> d;
497 iss2 >> m;
7c673cae
FG
498 check_equal("German names: date", d, date(2005, Jun, 6));
499 check_equal("German names: month", m, greg_month(Dec));
11fdf7f2
TL
500 iss2 >> d;
501 iss2 >> gw;
7c673cae
FG
502 check_equal("German names: special value date", d, date(min_date_time));
503 check_equal("German names: short weekday", gw, greg_weekday(Tuesday));
504 de_facet->weekday_format("%A"); // long weekday
505 // Tuesday, Second Tuesday of Mar
11fdf7f2
TL
506 iss2.str("Dienstag Zweitens Dienstag von Mar");
507 iss2 >> gw;
508 iss2 >> nkd;
7c673cae
FG
509 check_equal("German names: long weekday", gw, greg_weekday(Tuesday));
510 check_equal("German names, nth_day_of_the_week_in_month",
511 nkd.get_date(2005), date(2005,Mar,8));
512 // Tuesday after
11fdf7f2
TL
513 iss2.str("Dienstag Nach");
514 iss2 >> fka;
7c673cae
FG
515 check_equal("German names, first_day_of_the_week_after",
516 fka.get_date(date(2005,Apr,5)), date(2005,Apr,12));
517 }
518
519 {
520 // test name replacement functions
521
522 // collections for adding to facet
523 const char* const month_short_names[]={"*jan*","*feb*","*mar*",
524 "*apr*","*may*","*jun*",
525 "*jul*","*aug*","*sep*",
526 "*oct*","*nov*","*dec*"};
527 const char* const month_long_names[]={"**January**","**February**","**March**",
528 "**April**","**May**","**June**",
529 "**July**","**August**","**September**",
530 "**October**","**November**","**December**"};
531 const char* const weekday_short_names[]={"day1", "day2","day3","day4",
532 "day5","day6","day7"};
533 const char* const weekday_long_names[]= {"Sun-0", "Mon-1", "Tue-2",
534 "Wed-3", "Thu-4",
535 "Fri-5", "Sat-6"};
536
537 std::vector<std::basic_string<char> > short_weekday_names;
538 std::vector<std::basic_string<char> > long_weekday_names;
539 std::vector<std::basic_string<char> > short_month_names;
540 std::vector<std::basic_string<char> > long_month_names;
541
542 std::copy(&weekday_short_names[0],
543 &weekday_short_names[7],
544 std::back_inserter(short_weekday_names));
545 std::copy(&weekday_long_names[0],
546 &weekday_long_names[7],
547 std::back_inserter(long_weekday_names));
548 std::copy(&month_short_names[0],
549 &month_short_names[12],
550 std::back_inserter(short_month_names));
551 std::copy(&month_long_names[0],
552 &month_long_names[12],
553 std::back_inserter(long_month_names));
554
11fdf7f2
TL
555 date dx(not_a_date_time);
556 date_input_facet* facetx = new date_input_facet();
7c673cae 557 std::stringstream ss;
11fdf7f2
TL
558 ss.imbue(std::locale(std::locale::classic(), facetx));
559 facetx->short_month_names(short_month_names);
560 facetx->short_weekday_names(short_weekday_names);
561 facetx->long_month_names(long_month_names);
562 facetx->long_weekday_names(long_weekday_names);
563 facetx->format("%a %b %d, %Y");
7c673cae 564 ss.str("day7 *apr* 23, 2005");
11fdf7f2
TL
565 ss >> dx;
566 check_equal("Short custom names, set via accessor function", dx.day_of_week(), greg_weekday(6));
567 check_equal("Short custom names, set via accessor function", dx.month(), greg_month(4));
7c673cae
FG
568 ss.str("");
569 ss.str("Sun-0 **April** 24, 2005");
11fdf7f2
TL
570 facetx->format("%A %B %d, %Y");
571 ss >> dx;
572 check_equal("Long custom names, set via accessor function", dx.day_of_week(), greg_weekday(0));
573 check_equal("Long custom names, set via accessor function", dx.month(), greg_month(4));
7c673cae
FG
574
575 }
576#else
577 check("This test is a nop for platforms with USE_DATE_TIME_PRE_1_33_FACET_IO",
578 true);
579#endif
580 return printTestStats();
581}
582