Replies: 2 comments
-
|
;-) there is no switch it is an automatic setting based on the configured timezone. see 16a7adc and https://github.com/ohAnd/dtuGateway/tree/develop?tab=readme-ov-file#timezone-configuration |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@ohAnd |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello together,
I noticed that in snapshot 2.2.093 a checkbox is added for daylight saving setting (ohAnd) and thought an automatic in-time switching would be helpful. This could be the code with ntpAutoDLS() to be called in 1 or some minutes intervals in the DTUgateway loop.
`// Function that gets current system epoch time
// timeinfo is public
struct tm timeinfo;
unsigned long getTime() {
time_t now;
if (!getLocalTime(&timeinfo)) {
Serial.println("Failed to obtain time");
return(0);
}
time(&now);
return now;
}
//// ntp time - offset in summertime 7200 else 3600
int lastCheckedDay = 0;
int lastCheckedHrs = 0;
int changeHrs = 0;
bool checkLastSunday(int month){
unsigned long curEpoch = getTime();
curEpoch += 7 * 24 * 60 * 60; // add one week
//https://www.epochconverter.com/programming/c
time_t rawtime = curEpoch;
struct tm ts;
ts = *localtime(&rawtime);
Serial.println("checkLastSunday (month + new month): " + String(month) + " new " + String(ts.tm_mon));
return (month != ts.tm_mon );
}
//--------------------------------------------------------------------------
// Auto daylight saving time switching:
void ntpAutoDLS(){
unsigned long curEpoch = getTime(); // if not already previously called to get actual timeinfo
if (timeinfo.tm_mday != lastCheckedDay){
lastCheckedDay = timeinfo.tm_mday;
}
if ( 0 != changeHrs){
if( lastCheckedHrs != timeinfo.tm_hour){
lastCheckedHrs = timeinfo.tm_hour;
}
}`
What do you think ?
Beta Was this translation helpful? Give feedback.
All reactions