diff --git a/include/boost/date_time/date_parsing.hpp b/include/boost/date_time/date_parsing.hpp index 34e39bd9..21f32496 100644 --- a/include/boost/date_time/date_parsing.hpp +++ b/include/boost/date_time/date_parsing.hpp @@ -15,7 +15,9 @@ #include #include #include -#include +#ifdef BOOST_NO_CXX11 + #include +#endif #include #include #include @@ -29,6 +31,16 @@ namespace boost { namespace date_time { +inline unsigned short string_to_ushort(std::string const& s) +{ +#ifdef BOOST_NO_CXX11 + return boost::lexical_cast(s); +#else + // TODO: lexical cast has some side effect on that makes the std::stoul work here + boost::lexical_cast(s); + return std::stoul(s); +#endif +} //! A function to replace the std::transform( , , ,tolower) construct /*! This function simply takes a string, and changes all the characters * in that string to lowercase (according to the default system locale). @@ -61,7 +73,7 @@ namespace date_time { inline unsigned short month_str_to_ushort(std::string const& s) { if((s.at(0) >= '0') && (s.at(0) <= '9')) { - return boost::lexical_cast(s); + return string_to_ushort(s); } else { std::string str = convert_to_lower(s); @@ -160,7 +172,7 @@ namespace date_time { switch(spec_str.at(pos)) { case 'y': { - year = boost::lexical_cast(*beg); + year = string_to_ushort(*beg); break; } case 'm': @@ -170,7 +182,7 @@ namespace date_time { } case 'd': { - day = boost::lexical_cast(*beg); + day = string_to_ushort(*beg); break; } default: break; @@ -185,6 +197,7 @@ namespace date_time { parse_undelimited_date(const std::string& s) { int offsets[] = {4,2,2}; int pos = 0; + //typename date_type::ymd_type ymd((year_type::min)(),1,1); unsigned short y = 0, m = 0, d = 0; @@ -200,7 +213,8 @@ namespace date_time { std::basic_string > tokenizer_type; tokenizer_type tok(s, osf); for(typename tokenizer_type::iterator ti=tok.begin(); ti!=tok.end();++ti) { - unsigned short i = boost::lexical_cast(*ti); + unsigned i = string_to_ushort(*ti); + switch(pos) { case 0: y = i; break; case 1: m = i; break;