yeison / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

yaml.dump or yaml.load Dates with less than 4 digits for the year are not parsable #119

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
# Dates with less than 4 digit for the year are not parsable
# example with really old date - using SnakeYAML-1.8
foo: !!timestamp '2-11-30T06:00:00Z'
...

I understand the ambiguity of the timestamp, but maybe the dump should produce
!!timestamp '0002-11-30T06:00:00Z'
which the load is able to read in correctly

The dump produces the first example above, but when trying to read in the 
timestamp I get:
Main thread caught exception: org.yaml.snakeyaml.error.YAMLException: 
Unexpected timestamp: 2-11-30T06:00:00Z
org.yaml.snakeyaml.error.YAMLException: Unexpected timestamp: 2-11-30T06:00:00Z
    at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlTimestamp.construct(SafeConstructor.java:303)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:181)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:324)
    at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:144)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:305)
    at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:460)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:181)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:140)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:126)
    at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:296)
    at org.yaml.snakeyaml.Yaml.load(Yaml.java:266)

Original issue reported on code.google.com by firehoo...@gmail.com on 2 Jun 2011 at 8:38

GoogleCodeExporter commented 9 years ago
Sorry for the repeat of an already fixed (in 1.9-SNAPSHOT) issue 109 
http://code.google.com/p/snakeyaml/source/detail?r=38bdcad501c198de9188e9ea043c8
12bd9ed3dbe 

Original comment by firehoo...@gmail.com on 3 Jun 2011 at 12:44

GoogleCodeExporter commented 9 years ago

Original comment by alexande...@gmail.com on 3 Jun 2011 at 5:43