Closed
Description
Currently, YAML timestamps are pased into integers representing a Unix timestamp:
symfony/src/Symfony/Component/Yaml/Inline.php
Line 487 in f940d92
however, this is not very handy:
- it does not allow knowing that a YAML timestamp was provided (as it parses the same than an integer)
- dumping again the parsed data would not generate the same data (it will dump an integer, not a timestamp).
Dumping a YAML timestamp is actually impossible currently (if you format it as a YAML timestamp manually in a PHP string, it will be dumped as a string because the dumper knows that the string needs to be escaped).
So here is my proposal:
- make the dumper accept DateTimeInterface objects and dumping them as Yaml timestamps (they are currently dumped as PHP objects like other objects, or more likely throwing an exception as the object dumping is forbidden by default)
- add an option in the parser to parse timestamps as DateTime objects rather than integers. this option would be disabled by default for BC reasons, but I suggest that 3.0 could change it to become enabled by default.
What do you think about it ?