File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 1818#include " icinga/eventcommand.hpp"
1919#include " icinga/host.hpp"
2020#include < boost/algorithm/string.hpp>
21+ #include < cmath>
2122#include < map>
2223#include < utility>
2324#include < vector>
@@ -245,7 +246,18 @@ String IcingaDB::GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj)
245246}
246247
247248long long IcingaDB::TimestampToMilliseconds (double timestamp) {
248- return static_cast <long long >(timestamp * 1000 );
249+ // In addition to the limits of the Icinga DB MySQL (0 - 2^64) and PostgreSQL (0 - 2^63) schemata,
250+ // years not fitting in YYYY may cause problems, see e.g. https://github.com/golang/go/issues/4556.
251+ // RFC 3339: "All dates and times are assumed to be (...) somewhere between 0000AD and 9999AD."
252+ //
253+ // The below upper limit includes a safety buffer to make sure the timestamp is within 9999AD in all time zones:
254+ // $ date -ud @253402214400
255+ // Fri Dec 31 00:00:00 UTC 9999
256+ // $ TZ=Asia/Vladivostok date -d @253402214400
257+ // Fri Dec 31 10:00:00 +10 9999
258+ // $ TZ=America/Juneau date -d @253402214400
259+ // Thu Dec 30 15:00:00 AKST 9999
260+ return std::fmin (std::fmax (timestamp, 0.0 ), 253402214400.0 ) * 1000.0 ;
249261}
250262
251263String IcingaDB::IcingaToStreamValue (const Value& value)
You can’t perform that action at this time.
0 commit comments