Opened 6 years ago
Closed 5 years ago
#12910 closed Bugs (fixed)
boost::date_time::time_input_facet throws when using %j alone
Reported by: | Owned by: | James E. King, III | |
---|---|---|---|
Milestone: | Boost 1.67.0 | Component: | date_time |
Version: | Boost 1.63.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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:
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?
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
Change History (5)
comment:1 by , 5 years ago
Owner: | changed from | to
---|
comment:3 by , 5 years ago
Status: | new → assigned |
---|
comment:4 by , 5 years ago
Milestone: | To Be Determined → Boost 1.67.0 |
---|
comment:5 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix merged to master; resolved.
Note:
See TracTickets
for help on using tickets.
%j specifies the day of the year (which begs the question: which year?), without specifying the year, why would it be valid? It'll be interesting to see how strptime handles this for reference.