kcjoon / as3corelib

Automatically exported from code.google.com/p/as3corelib
0 stars 0 forks source link

DateUtil.parseW3CDTF parses incorrectly when time has more than 3 decimal places #115

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
w3c spec permits any number of decimal places for seconds, but the library
only supports exactly 3. If more are passed, e.g. 05:30:15.1234567 then the
decimal part is interpreted as 1234567 milliseconds, instead of 0.1234567
seconds.

What steps will reproduce the problem?

trace( DateUtil.parseW3CDTF(" 2009-08-06T19:05:13.4841744Z"); 

Expected:
Thu Aug 6 20:05:13 GMT+0100 2009

Actual:
Thu Aug 6 21:25:54 GMT+0100 2009

(results may vary with timezone of course)

Please provide any additional information below.

This can be fixed by replacing the line:

 var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ?
Number(secondsArr.shift()) : 0;

with:

 var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ?
1000*parseFloat("0." + secondsArr.shift()) : 0; 

Original issue reported on code.google.com by peterj...@gmail.com on 6 Aug 2009 at 8:58

GoogleCodeExporter commented 8 years ago

Original comment by mikechambers on 21 Sep 2009 at 5:39

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r110.

Original comment by mikechambers on 22 Sep 2009 at 7:43

GoogleCodeExporter commented 8 years ago
Fix. Committed revision 110.

Thanks for the report and patch.

Original comment by mikechambers on 22 Sep 2009 at 7:43