1

Closed

IsoDateTimeConverter Produces Invalid Date Strings in IE9

description

The IsoDateTimeConverter produces date strings like the following:

2013-06-13T20:43:55.611
2013-06-13T20:43:55.6

If you consume the JSON that includes these time strings in the browser and attempt to parse these date strings with new Date(), the first one will parse fine cross-browser. However, the second one will fail in IE9, saying "Invalid Date," because it requires 3 digits in the milliseconds place of the string:

http://jsfiddle.net/b9chris/HaBP8/

Open that in IE9 and you'll see the first 3 entries parse out as Invalid Date. In IE10 and Chrome, they parse just fine.

Screenshot of IE9 failing to parse most date time strings attached.

An easy fix would be to format the milliseconds portion with 3 digits regardless of how it rounds.

file attachments

Closed Jun 20, 2013 at 2:01 AM by JamesNK
There are a number of settings to make json.net always write 3 millisecond digits

comments

SoopahMan wrote Jun 20, 2013 at 2:36 AM

Sure, but should the default behavior fail in IE9?

SoopahMan wrote Jun 20, 2013 at 7:22 AM

If you'd like to fix this so the library works out of the box in IE9 and below, here's the patch.