ISO 8601 parser and unparser

Additions to convert an ISO 8601 string to an NSCalendarDate and back


Description

ISO 8601 provides a standard unambiguous format (several, actually) for dates and times. Unfortunately, NSDateFormatter alone does not completely support ISO 8601; in particular, it does not support week dates or ordinal dates.

This came to my attention when I began writing a patch for Vienna to add support for the ttl element of RSS 2.0 and the updatePeriod, updateFrequency, and updateBase elements of RDF Site Summary 1.0's Syndication module (which it borrowed from Open Content Syndication). The latter prescribes a YYYY-MM-DDTHH:MM format for dates. Somehow, I got it into my head that it prescribed ISO 8601 format for dates (as opposed to only the YYYY-MM-DDTHH:MM format), which would have meant that NSDateFormatter wouldn't work.

So, that's why I wrote this parser. I won't need it for Vienna, since RSS 1.0 doesn't actually prescribe ISO 8601 format by name (simply one version of it, which should be perfectly doable with plain Cocoa date-formatting techniques). Adium, however, does use ISO 8601 format in its log format, and so this parser/unparser is being used in Adium X 1.0 and later.


Version history

Version 0.4 added the ability to specify a custom time separator character instead of ':'. This works on both the parsing and unparsing directions.

Version 0.3 fixed some bugs found by Colin Barrett.

In version 0.2, I added an unparser. Now you can go back and forth between NSCalendarDate and NSString.


Downloads

ISO-8601-parser-0.4.tbz
Objective-C source code and test programs, with Makefile, in a bzip2ed tarball.
128-bit FNV1 hash: 151c0a909bbbac2016fc08f386ee28a8
MD5 hash: b3cf69d362bb054a312fba7e2aafd6eb
SHA-1 hash: 9f3982b8f651a12678c4666443399fc3539020bb
ISO-8601-parser-0.3.tbz
Objective-C source code and test programs, with Makefile, in a bzip2ed tarball.
128-bit FNV1 hash: e447290e6255e9d97ed928a63f691097
MD5 hash: c7ffb4705df004b4e0b46189838da408
SHA-1 hash: 5674dff4ddcb384074884e198018a55cf80e4c42
ISO-8601-parser-0.2.tbz
Objective-C source code and test programs, with Makefile, in a bzip2ed tarball.
128-bit FNV1 hash: 1a9289a57a39d598cc9939746289b959
MD5 hash: c7ffb4705df004b4e0b46189838da408
SHA-1 hash: 5674dff4ddcb384074884e198018a55cf80e4c42
ISO-8601-parser-0.1.tbz
Objective-C source code and test program, with Makefile, in a bzip2ed tarball.
128-bit FNV1 hash: 02c275e5997b3663ec0b79353245d17a
MD5 hash: 9de91f9ba38d1ac35d1996f61a9c2179
SHA-1 hash: 4e33e1513554c2facc6e3e731d56b6da649915bc

MD5 and SHA1 signatures were created using the md5sum(1) and sha1sum(1) utilities from GNU coreutils.


2006-08-31 http://boredzo.org/iso8601parser
Valid XHTML 1.0! Valid CSS!