|
Boost : |
From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2002-04-24 13:31:22
From: "Powell, Gary" <powellg_at_[hidden]>
> ostringstream os;
>
> os << use_stringMonths << use_number_day_of_week << ym_delimiter(',')
> << mdy_order << time_delimiter(':') << date;
>
> "April 24,2002 3 12:10:34" etc.
Why not a time_put/strftime pattern string?
os << date::set_format( "%B %d,%Y %w %H:%M%:%S" ) << adate;
> I also fall into the camp that wants iostreams/locales and not
>"to_string" fns.
Agree - iostream and locale support are fundamental. A to_string
function is a convenience that can be built on top of streams:
std::string date::to_string( const char *format = "%x",
std::locale loc = std::locale() )
{
std::ostringstream os;
os.imbue( loc );
os << set_format( format ) << *this;
return os.str();
}
Mark
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk