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: Laurent Dupuy <pizzafroide@…> 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 James E. King, III, 5 years ago

Owner: changed from az_sw_dude to James E. King, III

comment:2 by James E. King, III, 5 years ago

%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.

Last edited 5 years ago by James E. King, III (previous) (diff)

comment:3 by James E. King, III, 5 years ago

Status: newassigned

comment:4 by James E. King, III, 5 years ago

Milestone: To Be DeterminedBoost 1.67.0

comment:5 by James E. King, III, 5 years ago

Resolution: fixed
Status: assignedclosed

Fix merged to master; resolved.

Note: See TracTickets for help on using tickets.