Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-04-29 12:52:22


On Sat, 29 Apr 2006 14:03:12 +0200, Thomas Lemaire wrote
> ** sorry if double posting, but I have not received my first mail,
> and also no answers... **
>
> Dear list,
>
> I encounter a bug while reading a time_duration object, here is a
> short test case, the results are obtained with boost 1.33.1, gcc4.0.3
>
> using namespace boost::posix_time;
> time_duration td1(0,0,0);
> std::stringstream ss1("14:23:11.345678");
> ss1 >> td1;
> std::cout << td1 << std::endl; // 14:23:11.345678
>
> time_duration td2(0,0,0);
> std::stringstream ss2("18353:23:11.345678");
> ss2 >> td2;
> std::cout << td2 << std::endl; // 18:53:23
>
> time_duration td3(0,0,0);
> std::stringstream ss3("318353:23:11.345678");
> ss3 >> td3;
> std::cout << td3 << std::endl; // 00:00:00
>
> If I compile with the flag
> CPPFLAGS += -DUSE_DATE_TIME_PRE_1_33_FACET_IO
> this works well.
>
> I hope this will help to fix it...

Hi Thomas -

Thx for the report. This is indeed a problem in 1.33. What's happened is
that the default time_duration format has been defined as %H:%M:%S%F -- and
unfortunately, %H is limited to 2 digits. One solution would be to loosen the
2 digit restriction on %H. Unfortunately, there are several contexts where
that won't work -- like when parsing a iso time (eg: 20051015T131211). Making
things even worse, there isn't a format specifier that allows for hours to be
of a variable length. So there's no way for the user to set the context so
that this is allowed...

So it looks like we're going to need a new format specifier (%HV maybe?) and
some new code to do this. I'm also doubtful that we'll be able to change the
default time duration format to do this so you don't have to mess with facets
to make this case work -- we'll see...

I'd like to fix this for 1.34 as this is pretty serious, but I can't make any
promises at this point.

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