This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: email.utils.mktime_tz Giving wrong result , by ignoring Timezone that comes from value of parsedate_tz .
Type: behavior Stage: resolved
Components: None Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Phyo.Arkar.Lwin, r.david.murray
Priority: normal Keywords:

Created on 2010-12-11 11:44 by Phyo.Arkar.Lwin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg123783 - (view) Author: Phyo Arkar Lwin (Phyo.Arkar.Lwin) Date: 2010-12-11 11:44
DESCRIPTION:

I am trying to parse Time Zone information out of email messages and i found out that mktime_tz is totally ignoring TimeZone information from parsedate_tz.


VERSION: 2.6.5
CODE and RESULTS:


from time import mktime
from email.utils import parsedate,parsedate_tz,formatdate,mktime_tz

parsedate_tz('Sat, 10 Apr 2004 03:50:19 +400')
>>> (2004, 4, 10, 3, 50, 19, 0, 1, -1, 14400)


mktime_tz(parsedate_tz('Sat, 10 Apr 2004 03:50:19 +400'))
>>>1081554619.0
mktime(parsedate('Sat, 10 Apr 2004 03:50:19'))
>>>1081545619.0

Same????

formatdate(mktime_tz(parsedate_tz('Sat, 10 Apr 2004 03:50:19 +400')))
>>>'Fri, 09 Apr 2004 23:50:19 -0000' # WRONG TOTALLY

Expected Result:
>>>'Sat, 10 Apr 2004 03:50:19 +400'
msg123796 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-11 15:31
mktime_tz is documented as turning the input into a *UTC* timestamp.  That's what your example shows it doing.

There is an open issue elsewhere in this tracker for providing a way to round-trip RFC2822 timestamps.
History
Date User Action Args
2022-04-11 14:57:10adminsetgithub: 54887
2010-12-11 15:31:24r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg123796

resolution: not a bug
stage: resolved
2010-12-11 11:51:39Phyo.Arkar.Lwinsettype: behavior
2010-12-11 11:47:04Phyo.Arkar.Lwinsettitle: email.utils.mktime_tz Giving wrong result , by ignoring Timezone that comes from value of parsedate . -> email.utils.mktime_tz Giving wrong result , by ignoring Timezone that comes from value of parsedate_tz .
2010-12-11 11:44:28Phyo.Arkar.Lwincreate