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

Thomas B. Passin tpassin@home.com
Mon, 19 Mar 2001 18:16:13 -0500


Andrew Kuchling had a very good idea -

> 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.
>
I favor a dictionary or an object that may contain or act like one.  In
favor of an object, you could add various conversion methods as it seems
they are needed, and still by backwards compatible with older methods.

Cheers,

Tom P