trac-13194: fix time input facet processing for %e

This commit is contained in:
James E. King, III
2017-12-21 15:38:20 -05:00
parent f6ab5fc0fd
commit b3b6ddd5ba
3 changed files with 22 additions and 5 deletions
+4 -1
View File
@@ -1088,9 +1088,12 @@ namespace date_time {
break;
}
case 'd':
case 'e':
{
try {
t_day = this->m_parser.parse_day_of_month(sitr, stream_end);
t_day = (*itr == 'd') ?
this->m_parser.parse_day_of_month(sitr, stream_end) :
this->m_parser.parse_var_day_of_month(sitr, stream_end);
}
catch(std::out_of_range&) { // base class for exception bad_day_of_month
match_results mr;
+11 -2
View File
@@ -43,7 +43,7 @@ bool failure_test(temporal_type component,
// for tests that are expected to fail quietly
template<class temporal_type>
bool failure_test(temporal_type component,
bool failure_test(temporal_type& component,
const std::string& input,
boost::posix_time::time_input_facet* facet)
{
@@ -411,8 +411,17 @@ do_all_tests()
boost::date_time::date_generator_parser<date, char> dgp; // default constructor
time_input_facet tif("%Y-%m-%d %H:%M:%s", fdp, svp, pp, dgp);
}
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
// trac 13194 (https://svn.boost.org/trac10/ticket/13194)
{
const std::string value = "December 07:27:10.435945 5 2017";
boost::posix_time::time_input_facet* facet = new boost::posix_time::time_input_facet("%B %H:%M:%s %e %Y");
boost::posix_time::ptime pt;
check("trac 13194 %e on \"5\" failbit set", !failure_test(pt, value, facet)); // proves failbit was not set
check_equal("trac 13194 %e on \" 5\" valid value", "2017-12-05T07:27:10.435945000", to_iso_extended_string(pt));
}
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
}
+7 -2
View File
@@ -80,7 +80,9 @@
<row>
<entry valign="top" morerows="1"><screen>%d</screen></entry>
<entry>Day of the month as decimal 01 to 31</entry>
<entry>
Day of the month as decimal 01 to 31. When used to parse input, the leading zero is optional.
</entry>
</row>
<row>
<entry><screen></screen></entry>
@@ -96,7 +98,10 @@
<row>
<entry valign="top" morerows="1"><screen>%e #</screen></entry>
<entry>Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space</entry>
<entry>
Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space.
When used to parse input, the leading space is optional.
</entry>
</row>
<row>
<entry><screen></screen></entry>