Comment #6 on issue 54 by
p...@pav.gr: Allow parsing date formats with the
I'm now certain that I'm using an older version of the source code but I
don't see how.
$ hg clone
http://jayrock.googlecode.com/hg/ jayrock
requesting all changes
adding changesets
adding manifests
adding file changes
added 64 changesets with 442 changes to 344 files
updating to branch default
cloning subrepo tools from
http://tools.jayrock.googlecode.com/hg
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 117 changes to 117 files
341 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd jayrock
$ hg heads
changeset: 63:7fd760ede5f9
tag: tip
user: azizatif
date: Wed Oct 10 18:53:17 2012 +0200
summary: Fixes issue #49
$ hg branches
default 63:7fd760ede5f9
The file src/Jayrock.Json/Json/Conversion/Converters/DateTimeImporter.cs is
the one I'm attaching here.
At the top of the file, you can see:
public class DateTimeImporter : ImporterBase
{
private static readonly string[] _formats = new string[]
{
"yyyy-MM-dd'T'HH:mm:ss.fffffffzzz",
"yyyy-MM-dd'T'HH:mm:ss.ffffzzz",
"yyyy-MM-dd'T'HH:mm:ss.fffzzz",
"yyyy-MM-dd'T'HH:mm:ss.ffzzz",
"yyyy-MM-dd'T'HH:mm:ss.fzzz",
"yyyy-MM-dd'T'HH:mm:sszzz",
"yyyy-MM-dd'T'HH:mm:ss.fffffzzz",
"yyyy-MM-dd'T'HH:mm:ss.ffffffzzz",
"yyyy-MM-dd'T'HH:mm:ss.ffffffffzzz",
"yyyy-MM-dd'T'HH:mm:ss.fffffffffzzz",
"yyyy-MM-dd'T'HH:mm:ss.ffffffffffzzz",
"yyyy-MM-dd",
};
...
...
protected override object ImportFromString(ImportContext context,
JsonReader reader)
{
...
...
return ReadReturning(reader,
DateTime.ParseExact(reader.Text, _formats, CultureInfo.InvariantCulture,
DateTimeStyles.None));
}
catch (FormatException e)
{
throw StringError(e);
}
}
DateTime.ParseExact is being used in ImportFromString and the allowed
formats are listed in the array above.
This call to DateTime.ParseExact, with these arguments, cannot
parse "2013-10-29T11:04:09.144Z".
Can you please confirm that your version of DateTimeImporter.cs is the same
as the one attached here? Because I'm pretty sure it isn't, your version
used XmlConvert.ToDateTime while this used DateTime.ParseExact.
Thanks.
Attachments:
DateTimeImporter.cs 5.7 KB