Opened 15 years ago

#1726 new Bugs

boost/date_time/posix_time/time_formatters.hpp incorrectly formats fractional seconds using global locale

Reported by: jplejacq@… Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.34.1 Severity: Problem
Keywords: locale Cc:

Description

The function boost::posix_time::to_iso_string_type() uses the ostream::operator<<() function to write the time. This later function will use the current global locale to format each of the elements of the time. In particular, when the global locale is set to en_US, the fractional will be formatted to be 123,456 when there are six digits, which is incorrect.

The proposed solution is to temporarily imbue the ostream with the classic locale to disable formatting. The attached patch only applies this to the fractional seconds but it would be more robust to apply to the other time components as well.

This type of error probably exists in other functions. In particular see Ticket #1674 which is the same error.

Attachments (2)

boost_date_time_posix_time_time_formatters_hpp.patch (875 bytes ) - added by jplejacq@… 15 years ago.
patch
boost-date-time-1726.patch (824 bytes ) - added by Dean Michael Berris 12 years ago.
Updated patch to apply cleanly to r68583 on trunk.

Download all attachments as: .zip

Change History (2)

by Dean Michael Berris, 12 years ago

Attachment: boost-date-time-1726.patch added

Updated patch to apply cleanly to r68583 on trunk.

Note: See TracTickets for help on using tickets.