Ticket #5126: date_time.patch
File date_time.patch, 7.2 KB (added by , 12 years ago) |
---|
-
libs/date_time/example/local_time/local_date_time.cpp
old new 24 24 local_date_time ny_time(date(2004, Aug, 30), hours(10), nyc, true); 25 25 26 26 typedef boost::date_time::time_facet<local_date_time, char> ldt_facet; 27 ldt_facet* timefacet = new ldt_facet("%Y-%b-%d %H:%M:%S %F %Z");27 ldt_facet* timefacet = new ldt_facet("%Y-%b-%d %H:%M:%S""%F %Z"); 28 28 std::locale loc(std::locale::classic(), timefacet); 29 29 30 30 std::cout << ny_time << std::endl; -
libs/date_time/test/posix_time/testtime_facet.cpp
old new 165 165 //reset the sign to always print 166 166 time_facet* f = new time_facet(); 167 167 ss.imbue(std::locale(ss.getloc(), f)); 168 f->time_duration_format("%+%H:%M:%S %F");168 f->time_duration_format("%+%H:%M:%S""%F"); 169 169 170 170 ss.str(""); 171 171 ss << td4 - td3; … … 348 348 } 349 349 350 350 { 351 wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S %F");352 teststreaming("widestream custom time no frac seconds %F operator: %Y-%b-%d %H:%M:%S %F", t,351 wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S" L"%F"); 352 teststreaming("widestream custom time no frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", t, 353 353 std::wstring(L"2004-Oct-13 18:01:56"), 354 354 std::locale(std::locale::classic(), wtimefacet)); 355 355 } 356 356 357 357 { 358 wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S %F");358 wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S" L"%F"); 359 359 #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS 360 teststreaming("widestream custom time with frac seconds %F operator: %Y-%b-%d %H:%M:%S %F", tf,360 teststreaming("widestream custom time with frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tf, 361 361 std::wstring(L"2004-Oct-13 18:01:56.000003000"), 362 362 std::locale(std::locale::classic(), wtimefacet)); 363 363 #else 364 teststreaming("widestream custom time with frac seconds %F operator: %Y-%b-%d %H:%M:%S %F", tf,364 teststreaming("widestream custom time with frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tf, 365 365 std::wstring(L"2004-Oct-13 18:01:56.000003"), 366 366 std::locale(std::locale::classic(), wtimefacet)); 367 367 #endif // BOOST_DATE_TIME_HAS_NANOSECONDS … … 395 395 396 396 397 397 { 398 wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S %F");398 wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S" L"%F"); 399 399 #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS 400 teststreaming("widestream time period frac seconds %F operator: %Y-%b-%d %H:%M:%S %F", tp,400 teststreaming("widestream time period frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tp, 401 401 std::wstring(L"[2004-Oct-13 18:01:56/2004-Oct-20 19:02:57.000002999]"), 402 402 std::locale(std::locale::classic(), wtimefacet)); 403 403 #else 404 teststreaming("widestream time period frac seconds %F operator: %Y-%b-%d %H:%M:%S %F", tp,404 teststreaming("widestream time period frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tp, 405 405 std::wstring(L"[2004-Oct-13 18:01:56/2004-Oct-20 19:02:57.000002]"), 406 406 std::locale(std::locale::classic(), wtimefacet)); 407 407 #endif // BOOST_DATE_TIME_HAS_NANOSECONDS -
libs/date_time/test/posix_time/testtime_input_facet.cpp
old new 117 117 118 118 time_input_facet* facet = new time_input_facet(); 119 119 std::locale loc(std::locale::classic(), facet); 120 facet->time_duration_format("%H:%M:%S %f");120 facet->time_duration_format("%H:%M:%S""%f"); 121 121 iss.imbue(loc); 122 122 123 123 iss.str("14:13:12.0 extra stuff"); … … 180 180 { /****** iso format tests (and custom 'scrunched-together formats) ******/ 181 181 time_input_facet *facet = new time_input_facet(); 182 182 facet->set_iso_format(); 183 facet->time_duration_format("%H %M%S%F"); // iso format183 facet->time_duration_format("%H""%M""%S""%F"); // iso format 184 184 std::stringstream ss; 185 185 ss.imbue(std::locale(std::locale::classic(), facet)); 186 186 ptime pt(not_a_date_time); … … 217 217 ss.exceptions(std::ios_base::failbit); // we need exceptions turned on here 218 218 int count = 0; 219 219 try { 220 facet->time_duration_format("%H %M%S%F");220 facet->time_duration_format("%H""%M""%S""%F"); 221 221 ss.str("not-a-date-time"); 222 222 ++count; 223 223 ss >> td; 224 224 check_equal("special value w/ hours flag", td, nadt); 225 225 ss.str(""); 226 facet->time_duration_format("%M %S%F");226 facet->time_duration_format("%M""%S""%F"); 227 227 ss.str("not-a-date-time"); 228 228 ++count; 229 229 ss >> td; 230 230 check_equal("special value w/ minutes flag", td, nadt); 231 231 ss.str(""); 232 facet->time_duration_format("%S %F");232 facet->time_duration_format("%S""%F"); 233 233 ss.str("not-a-date-time"); 234 234 ++count; 235 235 ss >> td; … … 257 257 // exception tests 258 258 std::ios_base::failure exc("failure"); 259 259 check("failure test w/ hours flag", 260 failure_test(td, "bad_input", exc, new time_input_facet("%H %M%S%F")));260 failure_test(td, "bad_input", exc, new time_input_facet("%H""%M""%S""%F"))); 261 261 check("silent failure test w/ hours flag", 262 failure_test(td, "bad_input", new time_input_facet("%H %M%S%F")));262 failure_test(td, "bad_input", new time_input_facet("%H""%M""%S""%F"))); 263 263 check("failure test w/ minute flag", 264 failure_test(td, "bad_input", exc, new time_input_facet("%M %S%F")));264 failure_test(td, "bad_input", exc, new time_input_facet("%M""%S""%F"))); 265 265 check("silent failure test w/ minute flag", 266 failure_test(td, "bad_input", new time_input_facet("%M %S%F")));266 failure_test(td, "bad_input", new time_input_facet("%M""%S""%F"))); 267 267 check("failure test w/ second flag", 268 failure_test(td, "bad_input", exc, new time_input_facet("%S %F")));268 failure_test(td, "bad_input", exc, new time_input_facet("%S""%F"))); 269 269 check("silent failure test w/ second flag", 270 failure_test(td, "bad_input", new time_input_facet("%S %F")));270 failure_test(td, "bad_input", new time_input_facet("%S""%F"))); 271 271 check("failure test w/ sec w/frac (always) flag", 272 272 failure_test(td, "bad_input", exc, new time_input_facet("%s"))); 273 273 check("silent failure test w/ sec w/frac (always) flag", … … 350 350 // Failure tests 351 351 // faliure tests for date elements tested in gregorian tests 352 352 time_input_facet* facet2 = new time_input_facet(); 353 facet2->time_duration_format("%H:%M:%S %f");353 facet2->time_duration_format("%H:%M:%S""%f"); 354 354 check("Failure test: Missing frac_sec with %f flag (w/exceptions)", 355 355 failure_test(td, "14:13:12 extra stuff", e_failure, facet2)); 356 356 time_input_facet* facet3 = new time_input_facet(); 357 facet3->time_duration_format("%H:%M:%S %f");357 facet3->time_duration_format("%H:%M:%S""%f"); 358 358 check("Failure test: Missing frac_sec with %f flag (no exceptions)", 359 359 failure_test(td, "14:13:12 extra stuff", facet3)); 360 360