[Boost-bugs] [Boost C++ Libraries] #12910: boost::date_time::time_input_facet throws when using %j alone

Subject: [Boost-bugs] [Boost C++ Libraries] #12910: boost::date_time::time_input_facet throws when using %j alone
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-03-17 10:59:17


#12910: boost::date_time::time_input_facet throws when using %j alone
-------------------------------------------+------------------------
 Reporter: Laurent Dupuy <pizzafroide@…> | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
  Version: Boost 1.63.0 | Severity: Problem
 Keywords: |
-------------------------------------------+------------------------
 With a format such as `"%j-%H:%M:%S"`,
 `boost::date_time::time_input_facet` throws an error because when using
 `"%j"`, the computation of the date is:
 {{{#!cpp
 date_type d(not_a_date_time);
 if (day_of_year > 0) {
   d = date_type(static_cast<unsigned short>(t_year-1),12,31) +
 date_duration_type(day_of_year);
 }
 }}}
 And `t_year` is 1400! I am in a situation where I need to parse such a
 date/time though...

 Instead couldn't the computation be as follows?
 {{{#!cpp
 date_type d(not_a_date_time);
 if (day_of_year > 0) {
   d = date_type(static_cast<unsigned short>(t_year), 1, 1) +
 date_duration_type(day_of_year - 1);
 }
 }}}
 If so, the result of parsing `"263-08:09:10"` would be `"1400-Sep-20
 08:09:10 UTC"`. (And I'm good with that.)

 Test exposing the problem: http://coliru.stacked-
 crooked.com/a/16f2f96ee808afa2

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12910>
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-03-17 11:03:12 UTC