[issue13284] email.utils.formatdate function does not handle timezones correctly.

2011-11-07 Thread Vitja Makarov

Vitja Makarov vitja.maka...@gmail.com added the comment:

Perhaps it's better to calculate utc-offset for each timestamp cause we never 
know what is correct timezone for given time.

That could be done in C:

localtime, utc_offset = time.localtime_ex(t)

Where localtime is the same as returned by localtime() and utc_offset is set to 
tm.tm_gmtoff.
If tm_gmtoff isn't available on the target platform time.timezone or 
time.altzone will be used depending on time.daylight.


Here is simple python version, that subtracts gmtime from localtime tuple:

import time

def calculate_utc_offset(t):

Returns localtime offset for given unix-time `t`

loco = time.localtime(t)
utc = time.gmtime(t)
odd = cmp(loco.tm_year, utc.tm_year) or cmp(loco.tm_yday, utc.tm_yday)
return (1440 * odd +
60 * (loco.tm_hour - utc.tm_hour) +
loco.tm_min - utc.tm_min))

--
versions: +Python 2.6, Python 3.1, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13284
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13284] email.utils.formatdate function does not handle timezones correctly.

2011-11-07 Thread Vitja Makarov

Vitja Makarov vitja.maka...@gmail.com added the comment:

I'm not quite sure. The problem is email.utils.formatdate doesn't respect TZ 
info changes since it uses time.timezone (or time.altzone) for utc offset. 

Btw it seems that issue 665194 should fix the problem.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13284
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13284] email.utils.formatdate function does not handle timezones correctly.

2011-11-03 Thread Vitja Makarov

Vitja Makarov vitja.maka...@gmail.com added the comment:

We have the same issue in Russia (MSK timezone). It seems to be related to 
recent changes in timezone info.

It looks like time.timezone is calculated incorrectly.

You can test that with attached script:

$ TZ=Europe/Moscow python /tmp/test_tz.py
-10800 -14400

Both values should be the same.

--
nosy: +Vitja.Makarov
Added file: http://bugs.python.org/file23605/test_tz.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13284
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com