Boost logo

Boost Users :

From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2006-09-25 14:32:31


"Jeff Garland" <jeff_at_[hidden]> skrev i meddelandet
news:4517DA19.7010308_at_crystalclearsoftware.com...
> Johan Nilsson wrote:
>> Hi,
>>
>> is there any way to force ptime stream input fail when the time duration
>> part is not between 00:00:00 and 23:59:59?
>>

[snip]

> Since these are treated as a time_duration for i/o there isn't a switch in
> the
> library to do this. I think the easiest way to do this would be to break
> down
> the streaming into it's parts and check in your client code. Here's the
> sketch if how it can be trivially done:
>
> ptime getTime(istream& is)
> {
> //assuming formatting is already set...
> date d;
> time_duration td;
> is >> d;
> is >> td;
> if (td > hours(24)) {
> throw ....
> }
> return ptime(d, td);
> }

That's what I suspected. Thanks for the tip.

// Johan


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