|
Boost : |
Subject: Re: [boost] [date time] std::out_of_range thrown on date 2012-5-29
From: Pekka Seppänen (pekka.seppanen_at_[hidden])
Date: 2013-08-08 03:47:36
On 8.8.2013 10:13, Matthijs Möhlmann wrote:
> Hello all,
>
> Following piece of program gives a std::out_of_range exception:
>
> datetime = boost::posix_time::time_from_string("2012-5-29");
Hi,
time_from_string() expects the string contain both date *and* time. So you're
simply feeding it with a bad data.
I must say that the source for this exception (basic_string::at) is a bit
misleading. By looking at code it is probably thrown from
str_from_delimited_time_duration() as it doesn't check if its fed with an
empty basic_string (as quite likely happens in this case) and always calls at(0).
Maybe somebody (you?) could write a patch that does a little bit more checking
or add a note to documentation about this behavior.
-- Pekka
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk