pull/32571/head
Shane Smiskol 1 year ago
parent 4f223bcf70
commit 5d747dc7f3
  1. 20
      common/util.cc
  2. 2
      common/util.h
  3. 2
      selfdrive/ui/qt/maps/map.cc

@ -12,6 +12,10 @@
#include <iomanip>
#include <random>
#include <sstream>
#include <iostream>
#include <filesystem>
#include <chrono>
#include <ctime>
#ifdef __linux__
#include <sys/prctl.h>
@ -271,4 +275,20 @@ std::string check_output(const std::string& command) {
return result;
}
const std::chrono::system_clock::time_point _MIN_DATE = std::chrono::system_clock::from_time_t(std::mktime(new std::tm{0, 0, 0, 30, 2, 2024 - 1900}));
std::chrono::system_clock::time_point min_date() {
std::filesystem::path systemd_path("/lib/systemd/systemd");
if (std::filesystem::exists(systemd_path)) {
auto ftime = std::filesystem::last_write_time(systemd_path);
auto stime = std::chrono::time_point_cast<std::chrono::system_clock::duration>(ftime - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now());
return stime + std::chrono::hours(24);
}
return _MIN_DATE;
}
bool system_time_valid() {
return std::chrono::system_clock::now() > min_date();
}
} // namespace util

@ -99,6 +99,8 @@ inline void sleep_for(const int milliseconds) {
}
}
bool system_time_valid();
} // namespace util
class ExitHandler {

@ -122,6 +122,8 @@ void MapWindow::updateState(const UIState &s) {
const SubMaster &sm = *(s.sm);
update();
qDebug() << "time valid:" << util::system_time_valid();
if (sm.updated("liveLocationKalman")) {
auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman();
auto locationd_pos = locationd_location.getPositionGeodetic();

Loading…
Cancel
Save