6 xml.utils.iso8601

The xml.utils.iso8601 module provides conversion routines between the ISO 8601 representations of date/time values and the floating point values used elsewhere in Python. The floating point represtentation is particularly useful in conjunction with the standard time module.

Currently, this module supports a small superset of the ISO 8601 profile described by the World Wide Web Consortium (W3C). This is a subset of ISO 8601, but covers the cases expected to be used most often in the context of XML processing and Web applications. Future versions of this module may support a larger subset of ISO 8601-defined formats.

parse(s)
Parse an ISO 8601 date representation (with an optional time-of-day component) and return the date in seconds since the epoch.

parse_timezone(timezone)
Parse an ISO 8601 time zone designator and return the offset relative to Universal Coordinated Time (UTC) in seconds. If timezone is not valid, ValueError is raised.

tostring(t[, timezone])
Return formatted date/time value according to the profile described by the W3C. If timezone is provided, it must be the offset from UTC in seconds specified as a number, or time zone designator which can be parsed by parse_timezone(). If timezone is specified as a string and cannot be parsed by parse_timezone(), ValueError will be raised.

ctime(t)
Return formatter date/time value using the local timezone. This is equivalent to "tostring(t, time.timezone)".

See Also:

International Organization for Standardization. Data elements and interchange formats -- Information interchange -- Representation of dates and times. International Organization for Standardization, 1988.

Gary Houston. ISO 8601 date/time representations. January 1993. Available online as compressed PostScript: ftp://ftp.informatik.uni-erlangen.de/pub/doc/ISO/ISO8601.ps.Z.

Markus Kuhn. A Summary of the International Standard Dateand Time Notation. Available online at http://www.cl.cam.ac.uk/~mgk25/iso-time.html.

Misha Wolf and Charles Wicksteed. Date and Time Formats. World Wide Web Consortium Technical Note, September 1998. Available online at http://www.w3.org/TR/NOTE-datetime.