Modify

Opened 9 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:

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

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by anonymous

comment:1 Changed 6 years ago by mikhailberis

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

Changed 6 years ago by mikhailberis

Updated patch to apply cleanly to r68583 on trunk.

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

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

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

comment:4 Changed 6 years ago by marshall

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain az_sw_dude.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.