Boost logo

Boost Users :

Subject: [Boost-users] [date_time] Delimiters are ignored
From: Vadim Guchenko (nomail_at_[hidden])
Date: 2009-12-23 09:29:35


Hello, All!

Why the following code works while input string has wrong delimiters and too
large value of seconds?

#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
#include <sstream>
#include <string>
#include <locale>

int main() {
        std::string str("08a02b61 15c10d2008");
        std::istringstream is(str);
        is.imbue(std::locale(is.getloc(),
            new boost::posix_time::time_input_facet(
            "%H:%M:%S %d/%m/%Y")));

        boost::posix_time::ptime ptime;
        is >> ptime;
        if (is)
                std::cout << ptime << "\n";
        else
                std::cout << "Error\n";
}

It outputs:
2008-Oct-15 08:03:01

--
Best regards, Vadim Guchenko [yhw at relost dot net].

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