1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "base/convert.hpp"
4 #include "base/datetime.hpp"
5 #include <boost/lexical_cast.hpp>
7 using namespace icinga;
9 String Convert::ToString(const String& val)
14 String Convert::ToString(const Value& val)
19 String Convert::ToString(double val)
22 double fractional = std::modf(val, &integral);
25 return Convert::ToString(static_cast<long long>(val));
27 std::ostringstream msgbuf;
28 msgbuf << std::fixed << val;
32 double Convert::ToDateTimeValue(double val)
37 double Convert::ToDateTimeValue(const Value& val)
41 else if (val.IsObjectType<DateTime>())
42 return static_cast<DateTime::Ptr>(val)->GetValue();
44 BOOST_THROW_EXCEPTION(std::invalid_argument("Not a DateTime value."));