time.daylight (Daylight Saving Time)

John J. Lee jjl at pobox.com
Mon Nov 5 13:54:00 EST 2001


On Mon, 5 Nov 2001, Richard van de Stadt wrote:
[...]
> time.__docs__ shows this, concerning DST:
>
> ---
> DST (Daylight Savings Time) flag (-1, 0 or 1)
> If the DST flag is 0, the time is given in the regular time zone;
> if it is 1, the time is given in the DST time zone;
> if it is -1, mktime() should guess based on the date and time.
> ---
>
> However, now that DST is over, time.daylight keeps on being 1 (on the
> 5 systems located in different time zones that I've tried).
>
> There's no time.py, so I'm clueless about how time.daylight is supposed
> to be updated. Any ideas? Is it perhaps only set at compile time (just
> guessing).

>From the library reference:

 daylight
      Nonzero if a DST timezone is defined.

So 1 is what it's supposed to be, all year round, if your timezone has
daylight savings time at any time of the year.  time.localtime does what's
required (returning the DST flag that you described above -- not the same
as time.daylight), based on the table in your C library:

 DST is Daylight Saving Time, an adjustment of the timezone by (usually)
 one hour during part of the year. DST rules are magic (determined by
 local law) and can change from year to year. The C library has a table
 containing the local rules (often it is read from a system file for
 flexibility) and is the only source of True Wisdom in this respect.


John




More information about the Python-list mailing list