[Tutor] Daylight saving time issue

Jaap Spies jaapspies@home.nl
Wed, 07 Nov 2001 15:57:40 +0000


Titu Kim [SMTP:kimtitu@yahoo.com] wrote:



>>
>>Hi,
>>   I am trying to determine a given date is in dst or
>>not. For instance, if i have month(mm), day(dd),
>>year(yyyy) information plus the beginning (00:00:01)
>>or ending (23:59:59) of this day, i would like to
>>determine the given date/time is in daylight saving
>>time. To make the situation complecated, i also have
>>to consider the day when day light saving time occurs,
>>which is in Oct and April each year. Any suggestion is
>>very appreciated.
>>
>>Thank you very much.
>>
>>Regards,
>>
>>Kim Titu 
>>

In general your problem is very complex as Alan Gauld
pointed out. However when you are in the USA (not in Verginia!)
or in Europe, things are more easy. You need Universal Time (UT), the 
standard offset of the time zone you are in and a set of formulae
to calculate the Julian Day Number of the date in question, etc.

Astronomy to the rescue: Jean Meeus: Astronomical Algoritms, second 
edition, 1998, Willmann-Bell Inc.

I'm in the proces of providing astrometric software for the Python
community (shameless self promoting :-)):

	http://pynovas.sourceforge.net/

on that page you find a link to:

	http://astrolabe.sourceforge.net/

You should check out astrolabe/lib/python/astrolabe/calendar.py

the function is is_dst(jd) (for USA style of DST)

Good luck!

Jaap Spies