Python Dateutil parse() parameters

301 views Asked by At

I am fairly new to Python and apologize in advance if this is a dumb question!

I am trying to use the parse() function to normalize the date and time I am receiving from some XMPP timestamps.

t1 = parse("20141126T03:44:18")
print t1

If I pass a string to parse as illustrated above, parse() behaves as expected. If I pass another function to parse() it fails to run with the following error:

    t1 = parse(msg.getTimestamp())
    print t1

AttributeError: 'NoneType' object has no attribute 'read'

Any guidance would be much appreciated.

1

There are 1 answers

0
Brad McAllister On

I figured it out. I had to do the following:
stamp = str(msg.getTimestamp()) t1 = parse(stamp) print t1