time.localtime add a parameter for timezone

Rhodri James rhodri at kynesim.co.uk
Mon Feb 24 12:43:58 EST 2020


On 24/02/2020 17:21, Dieter Maurer wrote:
> qbit wrote at 2020-2-24 05:18 -0800:
>> How about adding a time zone parameter to time.localtime?
>>
>> A  offset just like the form: ± hh[:mm[:ss]].
> 
> Why should this be necessary? `localtime` returns the time
> in the "local timezone" -- and the "local timezone" usually
> does not change between different calls to `localtime`.

It can if your calls to localtime() happen either side of a daylight 
saving time switch.

That said, I agree that the timezone doesn't really belong in the output 
of localtime().  There are a very few occasions when you want it, but 
more often you should be working in UTC not local time.


-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list