Issue 4: _convert_datetime doesn't parse
Status:  New
Owner: ----
Reported by 4tmue...@gmail.com, Oct 2, 2012
What steps will reproduce the problem?
1. Have Mon, 01 Oct 2012 11:24:00 +0000 in your atom feed as published
2. try smth like feedformatter.Feed(feed=feedparser.parse().feed).atom_string
3. see it fail

Exception: Unrecongised time format! local Mon, 01 Oct 2012 11:24:00 +0000

Note that I had to pimp the exception in _convert_datetime. Please consider giving more helpful messages.

The strptime format currently is:  "%a, %d %b %Y %H:%M:%S %Z"

time.strptime yields:
ValueError: time data '%a, %d %b %Y %H:%M:%S %Z' does not match format u'Mon, 24 Sep 2012 12:20:27 +0000'

No idea why it doesn't parse. But it's annoying.


Jun 3, 2015
#1 richard.m.tew@gmail.com
_convert_datetime is broken.  Note that isalnum() can never be true for a strptime string.  isalnum is something like "sdsds222323fd" put a space in there, a comma, a colon or a plus sign and it breaks.  These are implicit parts of a strptime formatted date string.  It'd be better to do something like actually trying to convert the string to one of the cases and falling back to the other.

Apologies, but I do not have the time to set up a fork and submit a pull request.

        if time.isalnum():
            # String is alphanumeric - a time stamp?
            try:
                return strptime(time, "%a, %d %b %Y %H:%M:%S %Z")
            except ValueError:
                raise Exception("Unrecongised time format!")        
        else:
            # Maybe this is a string of an epoch time?
            try:
                return localtime(float(time))
            except ValueError:
                # Guess not.
                raise Exception("Unrecongised time format!")