Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2005-06-22 23:29:26


On Thu, 23 Jun 2005 00:16:42 +0400, Serge Skorokhodov wrote
> Hi,
>
> The following code (boost 1.32, MSVC.NET 2003):
>
> ptime pt = from_iso_string("20030912T211733.01204");
> cout << pt << endl;
> cout << to_simple_string(pt) << endl;
> cout << to_iso_extended_string(pt) << endl;
> cout << to_iso_string(pt) << endl;
> cout << pt.time_of_day().fractional_seconds() << endl;
> time_duration td = pt.time_of_day();
> cout << to_iso_string(td) << endl;
> cout << to_simple_string(td) << endl;
> cout << td.fractional_seconds() << endl;
>
> yealds:
>
> 2003-Sep-12 21:17:33
> 2003-Sep-12 21:17:33
> 2003-09-12T21:17:33
> 20030912T211733
> 0
> 211733
> 21:17:33
> 0
>
> Is the fractional part of time (.01204) absent by design? I failed to
> find it out from the documentation? Is there a workaround?

Hmm, that looks like a but to me -- should have the .01204 on the end. Will
put that on the to fix list. Note that in the current CVS you can use the new
facets to define the format however you like:
  ptime t(...);
  time_facet* output_facet = new time_facet("%Y-%m-%d %H:%M:%S%F");
  cout.imbue(locale(locale::classic(), output_facet));
  cout << t; //iso extended

There's also a method to do this:
   
  output_facet->set_iso_extended_format();

Input facet is similar. The other nice thing is the new facets don't require
you to build the library like the old 'to_string' functions -- so unless you
use the 'to_string' functions or serialization you'll be able to skip the
library build/link in 1.33. And support for localization is much better as
well. All in all 1.33 will be the way to go in a few days...

Fairly up to date docs for the upcoming release can be found at:

http://engineering.meta-comm.com/resources/cs-win32_metacomm/doc/html/date_time/date_time_io.html

Jeff


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