jsumners / feedparser

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

Datetime with swapped year/timezone parsed incorrectly #404

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
While moving from Feedparser 5.1 to 5.1.3 the time detection changed in some 
ways.

With Feedparser 5.1 a string ``'Sun Jul 15 00:15:00 +0000 2012'`` was correctly 
recognized as

time.struct_time(tm_year=2012, tm_mon=7, tm_mday=15, tm_hour=0, tm_min=15, 
tm_sec=0, tm_wday=6, tm_yday=197, tm_isdst=0)

. After the updated it is recognized as

time.struct_time(tm_year=2000, tm_mon=7, tm_mday=15, tm_hour=0, tm_min=0, 
tm_sec=0, tm_wday=5, tm_yday=197, tm_isdst=0)

which is, obviously, not what we want.

To make this actually work with 5.1.3 I created my on parser using the dateutil 
library:

import dateutil
def dateutilDateHandler(aDateString):
    return dateutil.parser.parse(aDateString).utctimetuple()
feedparser.registerDateHandler(dateutilDateHandler)

Original issue reported on code.google.com by jammamar...@gmail.com on 29 May 2013 at 3:53

GoogleCodeExporter commented 9 years ago
Thanks for reporting this!

I replaced at least one of the date parsers because it contained code that was 
obviously copied directly from the Python standard library without attribution. 
However, I'll review this problem and see what can be done to resolve it.

Original comment by kurtmckee on 10 Jul 2014 at 4:47