WindowsAzure/azure-sdk-for-node — Issue #95: Milliseconds serialized incorrectly for iso8061date
Author: jcookems
Created: 2012-02-23 23:05:44+00:00
State: open

In iso8061date-tests.js, the testFormat test asserts that the following should be equal:
var datetime = Date.UTC(2011, 6, 17, 14, 0, 23, 270);
var datetimeAtom = "2011-07-17T14:00:23.0000270Z";
This is incorrect, because the first date has 270 milliseconds = 270000 microseconds, while the second has 27 microseconds.

In iso8061date.js

1. In the *format* function the padding for getUTCMilliseconds should be only 3 (not 7) because adding extra zeros between a digit and the decimal point changes the value.
2. In the *parse* function needs to ensure that the ms[0] needs to be right padded if the length of the string is less than 3 (because Azure Table omits right padding zeros), or if the string is longer than 3, the least signifigant digits need to be discarded (as Azure has 100-ns precision, while JavaScript has only 1-ms precision).

See the comments for https://github.com/WindowsAzure/azure-sdk-for-java/pull/12 for a similar issue that affects the Azure SDK for Java.