Boost logo

Boost Users :

From: Andrew (corsairx_at_[hidden])
Date: 2007-10-27 05:35:59


Hi all,
I'm trying to use the date time library to to do some string formatting
but I'm afraid there's something I'm missing. What I'd like to do is
feed in a string "05/Aug/2007 11:30" and convert it to an ISO formatted
string - could anyone point me in the right direction?

I've examined both the documentation and the sample code in
io_tutorial.cpp but I'm afraid it hasn't helped - the code below is as
far as I've gotten and simply returns the input string unchanged.

I'm using boost 1.34.1 with MSVC 2005.

Thanks much,
Andrew

//Begin snippit
string formatDate(string inpDate)
{
  stringstream ss;
  local_date_time checkDate(not_a_date_time);
  local_time_input_facet* input_facet = new local_time_input_facet();
  local_time_facet* output_facet = new local_time_facet();
        
  ss.imbue(locale(locale::classic(), output_facet));
  ss.imbue(locale(ss.getloc(), input_facet));

  input_facet->format("%d/%b/%Y %H:%M");
  output_facet->set_iso_format();

  ss << inpDate;

  return ss.str();
}


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