src/cxx_supportlib/Utils/JsonUtils.h in passenger-5.0.26 vs src/cxx_supportlib/Utils/JsonUtils.h in passenger-5.0.27

- old
+ new

@@ -206,30 +206,32 @@ if (timestamp == 0) { return Json::Value(Json::nullValue); } Json::Value doc; - time_t time = (time_t) timestamp / 1000000; - char buf[32]; + time_t wallClockTime = (time_t) (timestamp / 1000000ull); + char wallClockTimeStr[32]; size_t len; if (now == 0) { now = SystemTime::getUsec(); } - doc["timestamp"] = timestamp / (double) 1000000; - - ctime_r(&time, buf); - len = strlen(buf); + ctime_r(&wallClockTime, wallClockTimeStr); + len = strlen(wallClockTimeStr); if (len > 0) { // Get rid of trailing newline - buf[len - 1] = '\0'; + wallClockTimeStr[len - 1] = '\0'; } - doc["local"] = buf; + + doc["timestamp"] = timestamp / 1000000.0; + doc["local"] = wallClockTimeStr; if (timestamp > now) { - doc["relative"] = distanceOfTimeInWords(time) + " from now"; + doc["relative_timestamp"] = (timestamp - now) / 1000000.0; + doc["relative"] = distanceOfTimeInWords(wallClockTime, now / 1000000ull) + " from now"; } else { - doc["relative"] = distanceOfTimeInWords(time) + " ago"; + doc["relative_timestamp"] = (now - timestamp) / -1000000.0; + doc["relative"] = distanceOfTimeInWords(wallClockTime, now / 1000000ull) + " ago"; } return doc; }