From a5240dd3e5c47b8a74d1a02f50d813091ccdd841 Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Fri, 11 Mar 2022 14:42:41 +0100 Subject: [PATCH] Fixing time offset but day offset is actual not working --- lib/obp60task/OBP60Formater.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/obp60task/OBP60Formater.cpp b/lib/obp60task/OBP60Formater.cpp index 3f50922..b22ee19 100644 --- a/lib/obp60task/OBP60Formater.cpp +++ b/lib/obp60task/OBP60Formater.cpp @@ -28,9 +28,10 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ char buffer[bsize+1]; buffer[0]=0; //######################################################## + time_t tv = 0; if (value->getFormat() == "formatDate"){ - time_t tv=tNMEA0183Msg::daysToTime_t(value->value); tmElements_t parts; + time_t tv=tNMEA0183Msg::daysToTime_t(value->value); tNMEA0183Msg::breakTime(tv,parts); if(usesimudata == false) { if(String(dateFormat) == "DE"){ @@ -58,13 +59,24 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ } //######################################################## else if(value->getFormat() == "formatTime"){ + double timeInSeconds; double inthr; double intmin; double intsec; double val; + + if(timeZone > 0){ + timeInSeconds = value->value + timeZone * 3600; + timeInSeconds = int(timeInSeconds) % 86400; // Reduce to one day (86400s) + } + else{ + timeInSeconds = value->value + timeZone * 3600 + 86400; // Add one day + timeInSeconds = int(timeInSeconds) % 86400; // Reduce to one day (86400s) + } + + if(usesimudata == false) { - val=modf(value->value/3600.0,&inthr); - inthr += timeZone; + val=modf(timeInSeconds/3600.0,&inthr); val=modf(val*3600.0/60.0,&intmin); modf(val*60.0,&intsec); snprintf(buffer,bsize,"%02.0f:%02.0f:%02.0f",inthr,intmin,intsec);