Strange round-tripping when creating JsDates

Jan 8, 2014 at 7:44 PM
Edited Jan 8, 2014 at 7:44 PM
When the JsDateConstructor class creates a date from a string, it does the following steps
  1. Calls DateTime.Parse(..) to convert the string to a .NET DateTime
  2. Calls the New function to create a JsDate with that DateTime as it's Value
  3. Calls ToNumber() on the JsDate to get a double value
  4. Again calls the New function with the double value
Steps 3 and 4 seem a bit redundant and actually produce errors, where the milliseconds of the JsDate are different after steps 2 and 4. There's more info and a repo here

Is there a reason why it's done this way? Does it have to be, it seems like it's only going to cause errors?

RavenDB uses jint and I've submitted a pull-request to fix it there, see the changes I made