Ticket #208 (new defect)
Yaml doesn't parse ISO8601 datetimes if they do not include seconds.
| Reported by: | mythmon@… | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | pyyaml |
| Severity: | normal | Keywords: | |
| Cc: |
Description
When YAML sees a ISO8601 date, or a datetime that includes seconds, it returns the right Python objects. But if the datetime only goes out to minutes and doesn't include the seconds, a plain string is returned.
Here is an example from a python interactive session:
>>> yaml.__version__
'3.10
>>> yaml.load('2011-10-24')
datetime.date(2011, 10, 24)
>>> yaml.load('2011-10-24 12:00:00')
datetime.datetime(2011, 10, 24, 12, 0)
>>> yaml.load('2011-10-24 12:00')
'2011-10-24 12:00'
Attachments
Change History
comment:2 Changed 17 months ago by joe.pyyaml@…
The example in the linked page shows a bunch of examples of what should be acceptable.
To quote the spec you linked to:
A timestamp value represents a single point in time. This can be serialized using a subset of the ISO8601 format and the formats proposed by the W3C note on datetime. In addition, a more relaxed format is also supported for enhanced readability, using white space separation.
If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part may be omitted altogether, resulting in a date format. In such a case, the time part is assumed to be 00:00:00Z (start of day, UTC).
The fact that two items that are both '!!timestamp' return objects of different types that can't be compared is pretty painful.

According to the specification ( http://yaml.org/type/timestamp.html) the seconds must be present.