[XML-SIG] iso8601 module: re-creating an original date

Andrew Kuchling akuchlin@mems-exchange.org
Mon, 19 Mar 2001 14:01:18 -0500


I've noticed that xml.utils.iso8601 doesn't provide enough information
to allow parsing and then re-creating a date.  iso8601.parse() takes a
string and returns the value in seconds since the epoch.  There's no
way to tell if the original date string was '2000-01-01' or '2000' or
'2000-01-01T00:00'.  You also can't parse the date manually in the
event you want an mxDateTime instead of just seconds, which means you
can't handle very old or very futuristic dates.

I'd like to add support for being precise and figuring out exactly
what was provided, but we need to discuss the interface a bit.

One possible API: parse_tuple(string) which returns a 9-tuple like the
one from time.gmtime() or time.localtime(), except that fields not
provided are represented by None, not 0.  (This means you can't pass
the tuple to functions like time.mktime() without first converting
None to 0.)  An alternative interface would be to return a dictionary
of fields, or an object with attributes.

Thoughts?

--amk