date_time problem: where are fractional seconds?
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? TIA -- Serge
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_t... Jeff
Jeff Garland wrote:
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_t...
Thanks for the info. What about wide string support? I've compiled for UNICODE but used standard chars for date_time to work. -- Serge
On Thu, 23 Jun 2005 09:39:15 +0400, Serge Skorokhodov wrote
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_t...
Thanks for the info. What about wide string support? I've compiled for UNICODE but used standard chars for date_time to work.
Another improvement in 1.33 -- 1.32 wide streaming was a bit spotty. Facets are called -- wdate_facet, wtime_facet, wdate_input_facet, and wtime_input_facet. Operate on format streams as well. Jeff
participants (2)
-
Jeff Garland
-
Serge Skorokhodov