Boost logo

Boost Users :

From: Lothar Werzinger (lothar_at_[hidden])
Date: 2008-08-01 01:13:16


On Thursday 31 July 2008, Lothar Werzinger wrote:
> On Thursday 31 July 2008, Steven Watanabe wrote:
> > For wchar_t it might help to use wlocal_time_facet, e.g.
> >
> > In Christ,
> > Steven Watanabe
>
> I changed the code in the wide functions to use the wlocal_time_facet (see
> attached sample) and now both non wide and wide behave the same. Thanks for
> the hint!
> I still wonder why I can apply a local_time_facet. Intuition tells me it
> should either work or not compile. I never thought the facet could be
> wrong, as it compiled. Thanks again for pointing that out!

Oh and how can I pick the "right" facet in a template function like:

/// extraction operator to get a ISO formatted string from a DateTime.
template < class charT, class traits >
void operator >>= (
  boost::local_time::local_date_time const & rc_value,
  std::basic_string < charT, traits > & r_result
)
{
  std::basic_stringstream < charT, traits > os;
  
  // switch locale to ISO format
  boost::local_time::local_time_facet* output_facet =
    new boost::local_time::local_time_facet();
  output_facet->format(
    boost::local_time::local_time_facet::iso_time_format_extended_specifier
  );
  os.imbue(std::locale(std::locale("C"), output_facet));
  os << rc_value;
  r_result = os.str();
}

Lothar

-- 
Lothar Werzinger Dipl.-Ing. Univ.
framework & platform architect
Tradescape Inc. - Enabling Efficient Digital Marketplaces
1754 Technology Drive, Suite 128
San Jose, CA 95110
web: http://www.tradescape.biz

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net