Opened 15 years ago

Closed 11 years ago

#1674 closed Bugs (fixed)

date_time::date_formatting.hpp: incorrectly formats year using global locale

Reported by: jplejacq@… Owned by: az_sw_dude
Milestone: Boost 1.36.0 Component: date_time
Version: Boost 1.34.1 Severity: Problem
Keywords: locale formatting Cc:

Description

The function boost::date_time::ymd_formatter::ymd_to_string() uses the ostream<<() function to write the date. This later function will use the current global locale to format each of the elements of the date. In particular, when the global locale is set to en_US, the year will be formatted to be 2,008 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 year but it would be more robust to apply to the day and month components as well.

This type of error probably exists in other functions.

Attachments (2)

boost_date_time_date_formatting_hpp.patch (595 bytes ) - added by anonymous 15 years ago.
boost-date_time-1674.patch (699 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 (6)

comment:1 by Dean Michael Berris, 12 years ago

Is there a chance we can get this tested as well? Would you care to provide a minimal test case?

by Dean Michael Berris, 12 years ago

Attachment: boost-date_time-1674.patch added

Updated patch to apply cleanly to r68583 on trunk.

comment:2 by Olexiy Buyanskyy <olexiyb@…>, 11 years ago

Hi,

Any chances to have this bug fixed? I am using 1.46.1 and still see this issue. This is very unexpected and undocumented behaviour to get year with comma inside if locale is set to en_US.

comment:3 by Marshall Clow, 11 years ago

(In [72132]) Applied patch; refs #1674

comment:4 by Marshall Clow, 11 years ago

Resolution: fixed
Status: newclosed

(In [72330]) Merge fixes to release; Fixes #1674

Note: See TracTickets for help on using tickets.