  #endif
  
    if (tmp_panda->has_rtc){
      setenv("TZ","UTC",1);
      struct tm sys_time = get_time();
      struct tm rtc_time = tmp_panda->get_rtc();
  
      if (!time_valid(sys_time) && time_valid(rtc_time)) {
        LOGE("System time wrong, setting from RTC. "
             "System: %d-%02d-%02d %02d:%02d:%02d RTC: %d-%02d-%02d %02d:%02d:%02d",
 
</s> remove     if (!time_valid(sys_time) && time_valid(rtc_time)) {
 </s> add     if (!util::time_valid(sys_time) && util::time_valid(rtc_time)) { </s> remove       struct tm sys_time = get_time();
 </s> add       struct tm sys_time = util::get_time(); </s> remove   struct tm sys_time;
  gmtime_r(&rawtime, &sys_time);

  return sys_time;
}

bool time_valid(struct tm sys_time){
  int year = 1900 + sys_time.tm_year;
  int month = 1 + sys_time.tm_mon;
  return (year > 2020) || (year == 2020 && month >= 10);
}
 </s> add  </s> remove struct tm get_time(){
  time_t rawtime;
  time(&rawtime);
 </s> add 
    struct tm sys_time = util::get_time();
  #endif
  
    if (tmp_panda->has_rtc){
      setenv("TZ","UTC",1);
    struct tm sys_time = util::get_time();
      struct tm rtc_time = tmp_panda->get_rtc();
  
      if (!time_valid(sys_time) && time_valid(rtc_time)) {
        LOGE("System time wrong, setting from RTC. "
             "System: %d-%02d-%02d %02d:%02d:%02d RTC: %d-%02d-%02d %02d:%02d:%02d",
keep keep keep keep replace keep keep keep keep keep
 Store almanac on ublox poweroff (#20967)

* Store almanac on ublox poweroff

* send current UTC time

* move message building to ublox_msg.h 
selfdrive/boardd/boardd.cc