Parsing Atom Dates (ISO8601) in ColdFusion

by Pete Freitag

Need to parse the dates in an Atom feed? Atom feeds use ISO 8601 formatted dates, something like this; 1994-11-05T08:15:30-05:00 with a UTC offset, or like this: 1994-11-05T13:15:30Z in GMT. You can come across both formats in an Atom feed, the atom:modified element MUST have a timezone specified, while the atom:issued element MAY specify a timezone.

Before getting too far, I checked CFLib's date library, and sure enough I found a function called DateConvertISO8601 by David Satz. From my limited testing the function seams to work well for parsing Atom / ISO8601 dates.

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.

Comments

Pete Freitag

After looking at the code I realize that this method does not handle all formats (if you don't specify seconds, it will fail, or if you specify fraction of a second it will fail). I may end up writing my own

Jeff Lemmon

Hi Peter. Do you know of any custom CF tags that parse atom feeds? I have found a few for RSS 2.0 but have yet to find an atom parser. Thank you!

James Moberg

The link to the DateConvertISO8601 UDF is broken (because URL rewrites were set up when the website became "static".) The new URL is https://cflib.org/udf/DateConvertISO8601