From a253fe414ef41c824bb9e6f654f0b85423c437ae Mon Sep 17 00:00:00 2001 From: Tony Cabello <> Date: Fri, 31 Dec 2021 17:45:44 +0100 Subject: [PATCH] fix for gps time --- src/main/io/gps.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/io/gps.c b/src/main/io/gps.c index 2a7ba8f3b8..17e2e6a79a 100644 --- a/src/main/io/gps.c +++ b/src/main/io/gps.c @@ -1498,10 +1498,15 @@ static bool UBLOX_parse_gps(void) #ifdef USE_RTC_TIME //set clock, when gps time is available if (!rtcHasTime() && (_buffer.pvt.valid & NAV_VALID_DATE) && (_buffer.pvt.valid & NAV_VALID_TIME)) { - rtcTime_t temp_time = (_buffer.pvt.sec + _buffer.pvt.min * 60 + _buffer.pvt.hour * 3600 + _buffer.pvt.day * 86400 + - (_buffer.pvt.year - 70) * 31536000 + ((_buffer.pvt.year - 69) / 4) * 86400 - - ((_buffer.pvt.year - 1) / 100) * 86400 + ((_buffer.pvt.year + 299) / 400) * 86400) * 1000L; - rtcSet(&temp_time); + dateTime_t dt; + dt.year = _buffer.pvt.year; + dt.month = _buffer.pvt.month; + dt.day = _buffer.pvt.day; + dt.hours = _buffer.pvt.hour; + dt.minutes = _buffer.pvt.min; + dt.seconds = _buffer.pvt.sec; + dt.millis = (_buffer.pvt.nano > 0) ? _buffer.pvt.nano / 1000 : 0; //up to 5ms of error + rtcSetDateTime(&dt); } #endif break;