# Calculating British Summer Time?

Hi guys,

I'm making a project that I would like to be aware of British summer time.

I'm using a DS1307 which will return INTs for day of week (1-7, 7 being sunday), month (1-12) and day of month (1-x depending on month).

Has anyone done this, or know a straight forward way of doing this?

In Britain, summer time starts at 1am GMT on the last sunday in March and ends at 1am GMT (2am BST) on the last day in October.

I don't want to actually change the time in the DS1307 (which will be set to GMT), I just want my program to be aware so it can display the correct time.

Any help would be appreciated. Thanks

Iain.

Right approach, setting the RTC to UTC instead of to local time. Summer time start and end are known quantities and can be calculated for any given year. I then have a function that accepts a UTC time as input, and returns local time, whether summer or standard time.

This is what I’ve come up with so far, but the problem I am having is working out how to return a true if the current day is on or after the last sunday of March or October (where a false should be returned).

``````boolean isBST(int day, int month, int dow)
{
if (month < 3 || month > 10)  //January, February, Noember and December are not BST months.
{
return false;
}
if (month > 3 || month < 10)  //April to September are BST months.
{
return true;
}
// More stuff goes here......
}
``````

Use the day of the week (1-7 as in your original post). Determine the last day in March. If it's Sunday (7), then we're done. If not, then determine which day of the week it is and subtract that many days (1-6).

Hints: Date arithmetic is much easier if the dates are dealt with as serial numbers. This time library works great for me, and provides the time_t type which is basically Unix time. It also provides a host of other functions that are very handy, and a struct called tmElements_t which breaks out all the date/time parts. There are functions to convert from time_t to tmElements_t and vise-versa. Finally, it includes a second library to interface to the DS1307, however, I believe it requires the days of the week to be numbered 1-7 for Sun-Sat, even though this is not a strict requirement of the DS1307. But that is an internal matter for your code and shouldn't necessarily be visible to the user.

Thanks, I'll check it out.