I have made my rough ISO8601 parser available at:
http://www.limey.net/~fiji/perl/DateTime-Format-ISO8601-0.01.tar.gz
Since this is a rough first release there are huge things wrong with
it. An incomplete list is:
- No documentation
- Module name not settled yet
- Only parses Dates (no times, recurrences or durations... yet)
- Code is littered with XXX indicating areas of further thought
- Code is littered with debug stuff
- Code should be much cleaner before release
- The interface is nowhere near done
- Needs more tests (and tests of failure)
- Error handling doesn't exist
What it does do at the moment:
- Parses any valid ISO8601 date
- Allows you to pick which format categories to apply (but the
interface is awful!)
- Does selection by variable length (8+ characters)
- Reasonably efficient algorithm for picking which formats match
the user's categories
- Test suite works now (and is passed completely)
If you want to play with this either check out the test suite, or use
the following line as a basis:
PERL5LIB=lib perl -MDateTime::Format::ISO8601 -e 'print
DateTime::Format::ISO8601->parse_datetime(shift, shift)->datetime(), "\n"' 2003W011
The optional second argument is the formats to use. The valid formats are:
C: Complete (fully specified date)
R: Recuced Precision (less significant items are dropped)
T: Truncated (current items implied)
B: Basic (no separators)
E: Extended (with separators)
X: Expanded (extra years)
O: Ordinal date (day count from year)
W: Week date (day count from year)
The default is to try all of them (XWOTCREB).
You must always pass in E or B and C or R since each format has those types.
So if you only wanted to use Complete Basic items, pass in "CB".
-ben