[Tutor] Re: Tutor digest, Vol 1 #1183 - 8 msgs
Jeff Shannon
jeff@ccvcorp.com
Wed, 07 Nov 2001 09:20:58 -0800
> Message: 5
> Date: Tue, 6 Nov 2001 17:40:53 -0800 (PST)
> From: Titu Kim <kimtitu@yahoo.com>
> To: tutor@python.org
> Subject: [Tutor] Daylight saving time issue
>
> 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.
Read the docs for the time module. If your date is in a seconds-since-epoch format, you can use localtime() to return a
tuple, the last value of which is a flag indicating DST (1) or regular time (0). If your date is in month-day-year, then
check into strptime() to convert it to seconds-since-epoch, but beware that the standard time.strptime() is only available
on Unix. There *are* more portable replacements available, though--check Parnassus or Google. (Unfortunately I don't
remember specifically where to find this.)
Also, as someone else suggested, check into mxDateTime. I haven't looked at it myself, but I wouldn't be surprised if it
will handle all your date-conversion and analysis needs. :)
Jeff Shannon
Technician/Programmer
Credit International