Ticket #208 (new defect)

Opened 2 years ago

Last modified 27 hours ago

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:


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__
>>> yaml.load('2011-10-24'), 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'


Change History

comment:1 Changed 2 years ago by py4fun@…

According to the specification ( the seconds must be present.

comment:2 Changed 2 years 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.

comment:3 Changed 27 hours ago by maskodok <galihadiputro87@…>

The only thing more I could hope for is documentation of all these features (other than reading through the code).  Cipto Junaedy Is this in process? Can I help? About  Unit Link Terbaik di Indonesia Commonwealth Life Investra Link


Add a comment

Modify Ticket

Change Properties
<Author field>
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from xi. Next status will be 'new'
The owner will be changed from xi to anonymous. Next status will be 'assigned'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.