Opened 9 years ago

Closed 5 years ago

#8528 closed Bugs (duplicate)

time_input_facet doesn't support %e

Reported by: galbraithjoseph@… Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc:

Description

time_input_facet doesn't support the %e substitution for days without leading zero.

This means that the following code for parsing RFC 2822 dates fails:

auto time_facet = new boost::posix_time::time_input_facet;
time_facet->format("%a, %e %b %Y %H:%M:%S");

Test strings (note that time zone portion is not parsed):

Tue, 15 Jan 2013 06:50:21 -0700
Wed, 9 Jan 2013 12:33:57 -0700

Also note that the second date makes %a, %d %b %Y a non-starter.

The attached patch fixes the problem for me. The patch is against 1.51, but I check the 1.53 code and upon a brief code inspection it didn't appear to have changed significantly.

Note that I made no attempt to verify how it behaves on badly constructed input; I simply cloned the %d code and changed it to call parse_var_day_of_month() instead of parse_day_of_month().

Attachments (1)

time_facet_e.diff (833 bytes ) - added by galbraithjoseph@… 9 years ago.
patch adding support for %e to time_input_facet

Download all attachments as: .zip

Change History (3)

by galbraithjoseph@…, 9 years ago

Attachment: time_facet_e.diff added

patch adding support for %e to time_input_facet

comment:1 by anonymous, 7 years ago

There are a few of us out there who would benefit greatly from being able to parse date, hour, etc as single digits without the leading zeros. Some customers just give us data in that format.

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

Resolution: duplicate
Status: newclosed

Duplicate of #13194, for which a pull request was submitted. Closing as a duplicate.

Note: See TracTickets for help on using tickets.