Opened 10 years ago

Closed 6 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:


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 10 years ago.
boost-date_time-1674.patch (699 bytes) - added by Dean Michael Berris 7 years ago.
Updated patch to apply cleanly to r68583 on trunk.

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by anonymous

comment:1 Changed 7 years ago by Dean Michael Berris

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

Changed 7 years ago by Dean Michael Berris

Attachment: boost-date_time-1674.patch added

Updated patch to apply cleanly to r68583 on trunk.

comment:2 Changed 6 years ago by Olexiy Buyanskyy <olexiyb@…>


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 Changed 6 years ago by Marshall Clow

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

comment:4 Changed 6 years ago by Marshall Clow

Resolution: fixed
Status: newclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain az_sw_dude.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.