Boost logo

Boost Users :

From: Bart (bartmann.nsd_at_[hidden])
Date: 2005-11-12 08:00:17


On Fri, 11 Nov 2005 10:37:09 -0700, Sean Rohead wrote:

> I am trying to parse ISO datetime strings with millisecond resolution
> and the fractional seconds are being truncated. Am I doing something
> wrong in the following code?
>
> Thanks,
>
> Sean Rohead
>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> #include <string>
> #include "boost/date_time/posix_time/posix_time.hpp"
>
> using namespace std;
> using namespace boost::posix_time;
>
> void main()
> {
> string dateString1 = "20051004T151801";
> string dateString2 = "20051004T151801.123";
> ptime timestamp1(from_iso_string(dateString1));
> ptime timestamp2(from_iso_string(dateString2));
> cout << timestamp1 << endl;
> cout << timestamp2 << endl;
> }

This code worked as expected for me:
  2005-Oct-04 15:18:01
  2005-Oct-04 15:18:01.123000

Which version of date_time are you using?

Bart


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