[Boost-bugs] [Boost C++ Libraries] #13194: Time input facet is not able to parse '%e' day

Subject: [Boost-bugs] [Boost C++ Libraries] #13194: Time input facet is not able to parse '%e' day
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-09-05 18:15:02


#13194: Time input facet is not able to parse '%e' day
-------------------------------------------------+-------------------------
 Reporter: Artem Komisarenko | Owner: az_sw_dude
  <artem.komisarenko.zultys@…> |
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
  Version: Boost Release Branch | Severity: Problem
 Keywords: |
-------------------------------------------------+-------------------------
 According to documentation, '%e' time format means day of the month with
 leading space (' 1', ' 2'.. '31') instead of zero ('01', '02'.. '31' for
 '%d'). It looks like now time input facet is not able to parse this.

 {{{
 int main()
 {
   const std::string time = "December 07:27:10.435945 1 2017";
   boost::posix_time::time_input_facet* facet = new
 boost::posix_time::time_input_facet("%B %H:%M:%s %e %Y");

    std::stringstream ss;
    ss.imbue(std::locale(std::locale(), facet));
    ss << time;
    boost::posix_time::ptime pt;

    ss >> pt;
    std::cout << pt << std::endl;
 }
 }}}

 Following patch helps for me:

 {{{
 --- /usr/include/boost/date_time/time_facet.hpp.old 2017-09-05
 17:55:25.645625191 +0000
 +++ /usr/include/boost/date_time/time_facet.hpp 2017-09-05
 17:57:49.205625185 +0000
 @@ -1049,9 +1049,10 @@ 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;

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13194>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-09-05 18:22:05 UTC