### 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;
thedate=line_buf;
thedate=line_buf;
thedate=line_buf;
thedate=' ';
thedate=line_buf;
thedate=line_buf;
thedate=' ';
thedate=line_buf;
thedate=line_buf;
thedate=line_buf;
thedate=line_buf;
thedate='\0';

char thetime;
thetime=line_buf;
thetime=line_buf;
thetime=line_buf;
thetime=line_buf;
thetime=line_buf;
thetime=line_buf;
thetime=line_buf;
thetime=line_buf;
thetime='\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