google-code-export / feedparser

Automatically exported from code.google.com/p/feedparser
Other
1 stars 0 forks source link

Date parsing incorrectly #368

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the following feed 
http://www.boston.com/sports/baseball/redsox/extras/extra_bases/index.xml
2. The entry dates are formatted as : Mon, 30 Jul 2012 23:20:34 -0500
3. The entry[i].updated_parsed value is : 2012-07-31 04:20:34

What is the expected output? What do you see instead?
expected output should be 2012-07-30 23:20:34

What version of the product are you using? On what operating system?
5.0.1

Please provide any additional information below.

Original issue reported on code.google.com by bmard...@gmail.com on 31 Jul 2012 at 7:12

GoogleCodeExporter commented 9 years ago
I looked into this issue and I think feedparser is right here. I suppose that 
"-0500" is "US/Central", right? So here some code which uses a python timezone 
library (http://pytz.sourceforge.net/)

In [31]: import pytz
In [32]: from datetime import datetime
In [33]: from pytz import timezone

In [34]: utc = pytz.utc
In [36]: central = timezone('US/Central')

In [37]: loc_dt = central.localize(datetime(2012, 07, 30, 23, 20, 34))
In [38]: print loc_dt
2012-07-30 23:20:34-05:00

In [39]: print loc_dt.astimezone(utc)
2012-07-31 04:20:34+00:00

Original comment by schla...@gmail.com on 7 Sep 2012 at 8:29

GoogleCodeExporter commented 9 years ago
feedparser is returning the 9-tuple normalized to UTC. This is correct behavior.

Original comment by kurtmckee on 19 Nov 2012 at 4:29