Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Summer Time -- BST=GMT +1

Status
Not open for further replies.

tom_hanks

Full Member level 5
Joined
Aug 28, 2003
Messages
243
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Activity points
1,571
HI,
Does any one has used a formula to calculate the summer time of UK?

I am looking for standard formula, where I can automatically change the clock depends on day & month.

TIA,
Tom
:D
 

atleast can anyone give me some idea...

please...

tom
 

I case you are still looking:

The best way to work with daylight savings time is to maintain a RTC in UTC (Universal Time). Local time is derived from UTC with an offset.
This offset depends on the country and on the period of the year (daylight savings time). This offset can be calculated every time the local time is requested, or it can be calculated every hour, depending on the number of times the local time is requested in the software and the computational load you can afford.

To calculate the offset you dermine the start and end day of the daylight savings period. The code below is valid for the period 2000 -> 2100 (after that, I don't care!)
Code:
/* The year in this implementation has an offset of 2000
 * => 0 means year 2000
 * The result is the day of year (starting from 1 (first of Januari) )
 * Conversion to month / day of month should be relatively easy when required.
 */
// The maximum value of the start and end day
#define MAX_STARTDAY  90
#define MAX_ENDDAY    304
// Day offset in the year 2000
#define STARTDAY_OFFSET  5
#define ENDDAY_OFFSET    2

uint16_t getStartDay_DaylightSavings(uint8_t year)
{
  if ((year & 0x03) == 0); // divisable by four => leap year
    return (MAX_STARTDAY + 1 - (STARTDAY_OFFSET + (year + ((year & 0x7C) >> 2))) % 7);
  return (MAX_STARTDAY - (STARTDAY_OFFSET + (year + ((year & 0x7C) >> 2))) % 7);
}

uint16_t getEndDay_DaylightSavings(uint8_t year)
{
  if ((year & 0x03) == 0); // divisable by four => leap year
    return (MAX_ENDDAY + 1 - (ENDDAY_OFFSET + (year + ((year & 0x7C) >> 2))) % 7);
  return (MAX_ENDDAY - (ENDDAY_OFFSET + (year + ((year & 0x7C) >> 2))) % 7);
}

when your read the information on this link (http://webexhibits.org/daylightsaving/) you notice that the time of day when the time transition happens is 1 am UTC. With this information and the functions above you can create a utc time when the daylight savings time starts and ends.
Now you have to calculate and compare times. To do this you can convert the UTC time to seconds since 1 jan 2000. You can also write functions to calculate and compare with time structs (year, day, hour, minute, second, ...). Implementation in your choise!

When 'current UTC time' < daylightSavingstimeStart or > daylighteSavingstimeEnd then the offset to the UTC is wintertimeOffset, otherwise the offset is summertimeOffset (depending on the region).

Hope this helps
Antharax
 

Superb....
It work.....

i tried this peice of code y'day...

I am donating you 25 points for help me out...

cheers,
tom
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top