Code cleaning OBPExtensions.cpp

This commit is contained in:
norbert-walter 2022-04-10 16:12:44 +02:00
parent 3c83d644a1
commit 49c8a0ccb0
1 changed files with 6 additions and 16 deletions

View File

@ -231,11 +231,6 @@ SunData calcSunsetSunrise(GwApi *api, double time, double date, double latitude,
time_t t = 0; time_t t = 0;
time_t sunR = 0; time_t sunR = 0;
time_t sunS = 0; time_t sunS = 0;
int inthrSR = 0;
int intminSR = 0;
int inthrSS = 0;
int intminSS = 0;
bool sunDown = false;
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) { if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
@ -246,26 +241,21 @@ SunData calcSunsetSunrise(GwApi *api, double time, double date, double latitude,
// Sunrise // Sunrise
if (sr.hasRise) { if (sr.hasRise) {
sunR = (sr.riseTime + int(timezone * secPerHour) + 30) % secPerYear; // add 30 seconds: round to minutes sunR = (sr.riseTime + int(timezone * secPerHour) + 30) % secPerYear; // add 30 seconds: round to minutes
inthrSR = int (sunR / secPerHour); returnset.sunriseHour = int (sunR / secPerHour);
intminSR = int((sunR - inthrSR * secPerHour)/60); returnset.sunriseMinute = int((sunR - returnset.sunriseHour * secPerHour)/60);
} }
// Sunset // Sunset
if (sr.hasSet) { if (sr.hasSet) {
sunS = (sr.setTime + int(timezone * secPerHour) + 30) % secPerYear; // add 30 seconds: round to minutes sunS = (sr.setTime + int(timezone * secPerHour) + 30) % secPerYear; // add 30 seconds: round to minutes
inthrSS = int (sunS / secPerHour); returnset.sunsetHour = int (sunS / secPerHour);
intminSS = int((sunS - inthrSS * secPerHour)/60); returnset.sunsetMinute = int((sunS - returnset.sunsetHour * secPerHour)/60);
} }
// Sun control (return value by sun on sky = false, sun down = true) // Sun control (return value by sun on sky = false, sun down = true)
if ((t >= sr.riseTime) && (t <= sr.setTime)) if ((t >= sr.riseTime) && (t <= sr.setTime))
sunDown = false; returnset.sunDown = false;
else sunDown = true; else returnset.sunDown = true;
} }
// Return values // Return values
returnset.sunsetHour = inthrSS;
returnset.sunsetMinute = intminSS;
returnset.sunriseHour = inthrSR;
returnset.sunriseMinute = intminSR;
returnset.sunDown = sunDown;
return returnset; return returnset;
} }