time.daylight (Daylight Saving Time) 
Author Message
 time.daylight (Daylight Saving Time)

Hi,

I'm using time.tzname[time.daylight] to display the time zone. This worked
fine as long a Daylight Saving Time (DST) was valid, since time.tzname is
e.g. this:

Quote:
>>> tzname

('MET', 'MEST')

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).

Richard.



Fri, 23 Apr 2004 20:59:39 GMT  
 time.daylight (Daylight Saving Time)
On Mon, 05 Nov 2001 13:59:39 +0100, Richard van de Stadt

Quote:

>Hi,

Hi!

Quote:
>I'm using time.tzname[time.daylight] to display the time zone. This worked
>fine as long a Daylight Saving Time (DST) was valid

[. . .]

Quote:
>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).

I think you're misinterpreting dime.daylight. At

http://www.python.org/doc/current/lib/module-time.html

it says:

daylight
  Nonzero if a DST timezone is defined.

I think you want something more like:

Quote:
>>> import time
>>> timeTuple=time.localtime(time.time())
>>> time.tzname[timeTuple[8]]

'CST'

You might want to check that daylight is nonzero first.

Regards,
Matt



Sat, 24 Apr 2004 01:43:58 GMT  
 time.daylight (Daylight Saving Time)

[...]

Quote:
> 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



Sat, 24 Apr 2004 02:54:00 GMT  
 time.daylight (Daylight Saving Time)

Quote:

> On Mon, 05 Nov 2001 13:59:39 +0100, Richard van de Stadt

> >Hi,

> Hi!

> >I'm using time.tzname[time.daylight] to display the time zone. This worked
> >fine as long a Daylight Saving Time (DST) was valid

[...]

Quote:
> I think you want something more like:

> >>> import time
> >>> timeTuple=time.localtime(time.time())
> >>> time.tzname[timeTuple[8]]
> 'CST'

> You might want to check that daylight is nonzero first.

Got it.

Thanks.

Richard.



Sat, 24 Apr 2004 07:32:37 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. time zones, daylight saving time, and universal time

2. VisualWork, Time, and Daylight Savings TIme

3. Daylight saving Time issue...

4. Daylight Savings Time

5. Daylight saving time

6. gmt vs. labview daylight saving time XL

7. DayLight Saving Time in LabView

8. Daylight Saving Time flag in BIOS

9. gnat304 Daylight Saving Time problem (was: compiler errors in GNAT 304a (win95))

10. time, strptime, daylight saving

11. Disregard daylight saving time

12. Daylight Savings Time goof

 

 
Powered by phpBB® Forum Software