62{
63 std::string s(in);
64 std::replace(s.begin(), s.end(), 'T', ' ');
65
66 boost::posix_time::ptime t;
67
68
69 try {
70 t = boost::posix_time::time_from_string(s);
71 } catch (const std::exception& ex) {
72 std::ostringstream text;
73 text << "cannot parse " << value << " = \'" << in << "\': \"" << ex.what()
74 << "\" (ISO 8601 format (YYYY-MM-DD HH:MM:SS) is expected).";
75 throw std::runtime_error(text.str().c_str());
76 }
77
78
79 if (tz_ptr) {
80 try {
81 boost::local_time::local_date_time lt(
82 t.date(), t.time_of_day(), tz_ptr, boost::local_time::local_date_time::EXCEPTION_ON_ERROR);
83 TLOG_DEBUG(1) <<
"Build zone\'s time \'" << in <<
"\' => \'" << lt.to_string() <<
"\' using \'"
84 << tz_ptr->to_posix_string() << '\'';
85 t = lt.utc_time();
86 } catch (std::exception& e) {
87 std::ostringstream text;
88 text << "cannot parse " << value << " = \'" << in << "\' in time zone \"" << tz_ptr->to_posix_string() << "\": \""
89 << e.what() << '\"' << std::endl;
90 throw std::runtime_error(text.str().c_str());
91 }
92 }
93
94 return t;
95}
#define TLOG_DEBUG(lvl,...)