Search code examples
pythondatetimerfc3339

Convert an RFC 3339 time to a standard Python timestamp


Is there an easy way to convert an RFC 3339 time into a regular Python timestamp?

I've got a script which is reading an ATOM feed and I'd like to be able to compare the timestamp of an item in the ATOM feed to the modification time of a file.

I notice from the ATOM spec, that ATOM dates include a time zone offset (Z<a number>) but, in my case, there's nothing after the Z so I guess we can assume GMT.

I suppose I could parse the time with a regex of some sort but I was hoping Python had a built-in way of doing it that I just haven't been able to find.


Solution

  • No builtin, afaik.

    feed.date.rfc3339 This is a Python library module with functions for converting timestamp strings in RFC 3339 format to Python time float values, and vice versa. RFC 3339 is the timestamp format used by the Atom feed syndication format.

    It is BSD-licensed.

    http://home.blarg.net/~steveha/pyfeed.html

    (Edited so it's clear I didn't write it. :-)