Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#3876 closed Bugs (fixed)

%T format specifier with local_time_facet crashes with MSVC 9

Reported by: Claudio Bley Owned by: az_sw_dude
Milestone: Boost 1.42.0 Component: date_time
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

The following program crashes with MSVC9 when trying to write the local_date_time to the stringstream:

#include <boost/date_time/local_time/local_time.hpp> 
#include <iostream>
#include <string>
#include <sstream>

int
main()
{
    using namespace boost::posix_time;
    using namespace boost::local_time;

    time_zone_ptr utc;
    local_date_time now(microsec_clock::universal_time(), utc);

    local_time_facet* output_facet = new local_time_facet();
    local_time_input_facet* input_facet = new local_time_input_facet();

    std::stringstream ss;
    ss.imbue(std::locale(std::locale::classic(), output_facet));
    ss.imbue(std::locale(ss.getloc(), input_facet)); 

    // http://www.boost.org/doc/libs/1_41_0/doc/html/date_time/date_time_io.html#date_time.format_flags
    // %T !  The time in 24-hour notation (%H:%M:%S)
    output_facet->format("%T");

    ss << now; // crash in _Strftime_l
}

With MinGW 4.4.0 it just ignores the %T format specifier. What's the deal with %T?

Change History (4)

comment:1 by Andrey Semashev, 12 years ago

This placeholder is not standard, but Boost.DateTime doesn't handle it itself. This should either be mentioned in docs or fixed in the code.

comment:2 by Andrey Semashev, 12 years ago

(In [62450]) Refs #3876. Made format flags %T and %R to be processed by the library in order to support them on more platforms. Also marked some flags that are known to have similar problems in the docs.

comment:3 by Andrey Semashev, 12 years ago

Resolution: fixed
Status: newclosed

(In [62667]) Merged changes from trunk (rev. 62450). Fixes #3876.

comment:4 by Andrey Semashev, 12 years ago

(In [62669]) Merged changes from trunk (rev. 62450). Fixes #3876.

Note: See TracTickets for help on using tickets.