emonGLCD Daylight Savings - BST time

Would anyone find the following useful?

I'm a bit of a novice but I wrote the following to set British Summer Time(BST - Day Light Savings) - this is assuming you have already got GMT from a server.

It seems to work ok.

```//------------------..------------------------------------------------
// British summer time
//------------------------------------------------------------------
void setDayLightSavings(int bst){
DateTime now = RTC.now();

DateTime bstStart = DateTime(now.year(), 3, 31, 1,0,0); // End of march
int lastSun = bstStart.dayOfWeek();
bstStart = DateTime(now.year(),3,31-lastSun,1,0,0); // Last Sunday in March

DateTime bstStop = DateTime(now.year(), 10, 31, 1,0,0); // End of October
lastSun = bstStop.dayOfWeek();
bstStop = DateTime(now.year(),10,31-lastSun,1,0,0); // Last Sunday in October

// Date comparison by converting the month, day, and hour to a single long integer
// i.e. March 25 01:00= (3*10000)+(25*100)+01 = 32501
//      October 28 01:00 = (10*10000)+(28*100)+01 = 102801
// We then use the same on the current date to see if it falls between the two numbers
long s = ((long) bstStart.month()*10000)+(bstStart.day()*100+bstStart.hour());
long e = ((long) bstStop.month()*10000)+(bstStop.day()*100)+bstStop.hour();
long n = ((long) now.month()*10000)+(now.day()*100)+now.hour();
if ( (n>=s) && (n<e)){
RTC.adjust(DateTime(now.year(), now.month(), now.day(), now.hour()+1, now.minute(), now.second()));
bst=1;
}else{bst=0;}
}```

I should have added that set the date and time in the first place using the following from a server header:

```  get_header_line(2,off);      // Get the date and time from the header
Serial.println(line_buf);    // Print out the date and time

char thedate[12];
thedate[0]=line_buf[14];
thedate[1]=line_buf[15];
thedate[2]=line_buf[16];
thedate[3]=' ';
thedate[4]=line_buf[11];
thedate[5]=line_buf[12];
thedate[6]=' ';
thedate[7]=line_buf[18];
thedate[8]=line_buf[19];
thedate[9]=line_buf[20];
thedate[10]=line_buf[21];
thedate[11]='\0';

char thetime[9];
thetime[0]=line_buf[23];
thetime[1]=line_buf[24];
thetime[2]=line_buf[25];
thetime[3]=line_buf[26];
thetime[4]=line_buf[27];
thetime[5]=line_buf[28];
thetime[6]=line_buf[29];
thetime[7]=line_buf[30];
thetime[8]='\0';

Please let me know if anything is wrong...

Re: emonGLCD Daylight Savings - BST time

That looks promising. I nearly wrote something similar myself this morning, but ran out of time and ended up putting a temp bodge in place. Will try anduse it later this week.

Lloyd