I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 3.00
sub units 13.47
+
0
UnitsTime

summertime

viewed 2614 times and licensed 45 times
Calculates the start and end of summer time in the specified year and region.
Controller: CodeCogs

get GPL add to cart

Dependents

Info

Interface

C++

Overview

Most countries that observe daylight saving time are listed in the table below. They all save one hour in the summer and change their clocks some time between midnight and 3 am.

Continent Code Country Beginning and ending days
Africa st_Egypt Egypt Start: Last Friday in April
End: Last Thursday in September
st_Namibia Namibia Start: First Sunday in September
End: First Sunday in April
Asia st_FormerUSSR Most states of the Former USSR. Start: Last Sunday in March
End: Last Sunday in October
st_Iraq Iraq Start: April 1
End: October 1
st_Israel Israel (an approximation) (Estimate, Israel decides the dates every year)
Start: First Friday in April
End: First Friday in September

st_Lebanon

st_Kirgizstan

Lebanon, Kirgizstan Start: Last Sunday in March
End: Last Sunday in October
st_Palestine Palestine (an approximation) Start: First Friday on or after 15 April
End: First Friday on or after 15 October
st_Syria Syria Start: April 1
End: October 1
st_Iran Iran Start: the first day of Farvardin
End: the first day of Mehr
Australasia st_Australia Australia - South Australia, Victoria,
Australian Capital Territory, New South Wales,
Lord Howe Island
Start: Last Sunday in October
End: Last Sunday in March
st_Tasmania Australia - Tasmania Start: First Sunday in October
End: Last Sunday in March
st_NewZealand
st_Chatham
New Zealand, Chatham Start: First Sunday in October
End: Third Sunday in March
st_Tonga Tonga Start: First Sunday in November
End: Last Sunday in January
Europe st_EU European Union
UK
Start: Last Sunday in March at 1 am UTC
End: Last Sunday in October at 1 am UTC
st_Russia Russia Start: Last Sunday in March at 2 am local time
End: Last Sunday in October at 2 am local time
North America st_USA
st_Canada
st_Mexico
st_Bahamas
United States, Canada, Mexico
St. Johns, Bahamas, Turks and Caicos
Start: Second Sunday in March
End: First Sunday in November

(Post 2007 - no longer implemented)
Start: First Sunday in April
End: Last Sunday in October
st_Cuba Cuba Start: April 1
End: Last Sunday in October
st_Greenland Greenland Same as EU
South America st_Brazil Brazil (rules vary from year to year - and
equatorial Brazil does not observe DST)
Start: First Sunday in November
End: Third Sunday in February
st_Chile Chile
Start: Second Saturday of October
End: Second Saturday of March
st_Falklands Falklands Start: First Sunday on or after 8 September
End: First Sunday on or after 6 April
st_Paraquay Paraguay Start: First Sunday in September
End: First Sunday in April

SummerTime

 
voidsummerTimeintYear
double& StartDate
double& EndDate
summerTimeRegionRegion )
Calculates the start and end dates for summer time in the region specified. This information can be used to adjust the local time by adding 1hr to the local time during their summer. The majority of the calculations assume that switch over between summer and winter time occurs at mid-night (12am), unless otherwise specified (see summerTimeRegion). This function returns a real number that represents the exact date and time of the switch-over, with the date represented by a serial number of Julian days with time added using a fraction of a day, i.e

References:

www.webexhibits.org/daylightsaving

Example 1

#include <stdio.h>
#include <codecogs/units/time/summertime.h>
#include <codecogs/units/time/hour.h>
#include <codecogs/units/time/minute.h>
#include <codecogs/units/date/month_str.h>
#include <codecogs/units/date/month.h>
#include <codecogs/units/date/day.h>
#include <codecogs/units/date/date.h>
 
using namespace Units::Time;
using namespace Units::Date;
int main()
{
  for(int i=2004;i<2006;i++)
  {
    printf("\n In year %d",i);
    double start,end;
    summerTime(i, start, end, st_UK);
    printf("\n         UK Summer time runs from %2d %s\t%2d:%02d", day(int(start)),
month_str(month(int(start))), hour(start), minute(start));
    printf(" to %2d %s\t%2d:%02d", day(int(end)), month_str(month(int(end))), hour(end),
minute(end));

summerTime(i, start, end, st_Canada); printf("\n Canadian Summer time runs from %2d %s\t%2d:%02d", day(int(start)), month_str(month(int(start))), hour(start), minute(start)); printf(" to %2d %s\t%2d:%02d", day(int(end)), month_str(month(int(end))), hour(end), minute(end)); } return 0; }
Output:
In year 2004
UK Summer time runs from 28 March   1:00 to 31 October   1:00
Canadian Summer time runs from  4 April   0:00 to 31 October   0:00
In year 2005
UK Summer time runs from 27 March   1:00 to 30 October   1:00
Canadian Summer time runs from  3 April   0:00 to 30 October   0:00

Note

In the northern hemisphere the EndDate > StartDate. In the southern hemisphere, summertime crosses the new year, so EndDate < StartDate. For this reason if you want to check if your current date is in summer time, you must simply check the relative order of StartDate and EndDate.

Parameters

Yearis a 4 digit Gregorian year.
StartDateis a location (passed by reference) into which is placed the start date and time when summer time within Year occurs - the point when everyone adds 1hr to the times shown on their clocks.
EndDateis a location (passed by reference) into which is placed the end date and time for summer time - the point when everyone subtracts 1hr from the times shown on their clocks.

Authors

Will Bateman (Nov 2004)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.


SummerTime

 
boolsummerTimedoublenDate
summerTimeRegionRegion )
Calculates if the provided date occurs in summer time. You might use the result from this function to add 1 hour to nDate in order to factor in Summer time variations. Summer time is always applied some time between midnight (12am) and 3am, with this time being repeated twice during the transition from summer to winter time. To capture the transition correctly, it is important that nDate represents local time without summer time, such that the addition of 1hr is only added to during the summer. For example:
if(summerTime(somedate, st_UK)) somedate+=1/24.0;
N.B. You should not subtract 1hr from a summer time value in order to obtain standard time for the winter months, as this will yield slightly incorrect times at the transition from winter to summer (the changeover occurring 1 hour early).

Example 2

#include <stdio.h>
#include <codecogs/units/time/summertime.h>
#include <codecogs/units/date/day.h>
#include <codecogs/units/time/hour.h>
#include <codecogs/units/time/minute.h>
 
void main()
{
  double nDate=date("30 oct 2004");
  for(double i=22/24.0;i<26/24.0;i+=1/48.0)
  {
    double a=nDate+i;
    bool summer=summerTime(a, st_UK);
    a+=summer* 1/24.0;
    printf("\n %s day=%d time=%2d:%02d", summer?"Summer":"Winter", day(int(a)), hour(a), minute(a));
  }
}
Output:
Summer day=30 time=23:00
Summer day=30 time=23:30
Summer day=31 time= 0:00
Summer day=31 time= 0:30
Summer day=31 time= 1:00
Summer day=31 time= 1:30
Winter day=31 time= 1:00
Winter day=31 time= 1:30
Winter day=31 time= 2:00

Parameters

nDateis a serial number of days from 24 November 4714 BC (1 January 4713BC in the Julian Calendar) - also known as the Julian Period. Time during the day is representing using a fraction of the day, i.e. 1hr=1/24.0.

Authors

Will Bateman (Nov 2004)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.