Datetime.strptime - NonType error on second use
#10
(2012-10-12, 17:17)ronie Wrote: as far as i understand it's a known issue with python.
if you google for a bit, you'll find several reports like this one:
http://mail.python.org/pipermail/python-...40579.html

the workaround seems to be:
Code:
import datetime
import _strptime

Thanks but this didn't work. I think it might fix a slightly different problem to mine.
(2012-10-12, 18:28)divingmule Wrote: Here is how I worked around the issue in one add-on using time module -

Code:
try:
        start_date = datetime.strptime(url, "%B %d, %Y - %A")
    except TypeError:
        start_date = datetime.fromtimestamp(time.mktime(time.strptime(url, "%B %d, %Y - %A")))

Thanks, this works, but I ended up taking a simpler example from the Python doc.

Code:
try:
    datetime.strptime(date_string, format)
except TypeError:
    datetime(*(time.strptime(date_string, format)[0:6]))

I was hoping there wouldn't be a need to work around the problem but at least it's working now.
Leopold's Repository: Home of LibreELEC Dev Updater ...
Reply


Messages In This Thread
[No subject] - by takoi - 2011-10-23, 12:15
[No subject] - by Eldorado - 2011-10-24, 16:49
Same issue - by shanemeagher - 2011-12-20, 18:21
[No subject] - by Eldorado - 2011-12-20, 18:25
RE: - by Leopold - 2012-10-12, 15:36
[No subject] - by k_zeon - 2011-12-22, 15:29
RE: Datetime.strptime - NonType error on second use - by Leopold - 2012-10-15, 17:43
Logout Mark Read Team Forum Stats Members Help
Datetime.strptime - NonType error on second use1