| Index: lib/compiler/implementation/lib/mockimpl.dart
|
| diff --git a/lib/compiler/implementation/lib/mockimpl.dart b/lib/compiler/implementation/lib/mockimpl.dart
|
| index d6d8f5dc353dcc23da8a134c4f1f59022f97c6de..da80c14aa807b53ca08a0179fde9989a795b34bc 100644
|
| --- a/lib/compiler/implementation/lib/mockimpl.dart
|
| +++ b/lib/compiler/implementation/lib/mockimpl.dart
|
| @@ -229,7 +229,7 @@ class DateImplementation implements Date {
|
| // - "-123450101 00:00:00 Z" // In the year -12345.
|
| final RegExp re = const RegExp(
|
| @'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part.
|
| - @'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(?:.(\d{1,5}))?)?)? ?([zZ])?)?$');
|
| + @'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$');
|
| Match match = re.firstMatch(formattedString);
|
| if (match !== null) {
|
| int parseIntOrZero(String matched) {
|
| @@ -238,6 +238,12 @@ class DateImplementation implements Date {
|
| return Math.parseInt(matched);
|
| }
|
|
|
| + double parseDoubleOrZero(String matched) {
|
| + // TODO(floitsch): we should not need to test against the empty string.
|
| + if (matched === null || matched == "") return 0.0;
|
| + return Math.parseDouble(matched);
|
| + }
|
| +
|
| int years = Math.parseInt(match[1]);
|
| int month = Math.parseInt(match[2]);
|
| int day = Math.parseInt(match[3]);
|
| @@ -245,26 +251,10 @@ class DateImplementation implements Date {
|
| int minutes = parseIntOrZero(match[5]);
|
| int seconds = parseIntOrZero(match[6]);
|
| bool addOneMillisecond = false;
|
| - int milliseconds = parseIntOrZero(match[7]);
|
| - if (milliseconds != 0) {
|
| - if (match[7].length == 1) {
|
| - milliseconds *= 100;
|
| - } else if (match[7].length == 2) {
|
| - milliseconds *= 10;
|
| - } else if (match[7].length == 3) {
|
| - // Do nothing.
|
| - } else if (match[7].length == 4) {
|
| - addOneMillisecond = ((milliseconds % 10) >= 5);
|
| - milliseconds ~/= 10;
|
| - } else {
|
| - assert(match[7].length == 5);
|
| - addOneMillisecond = ((milliseconds %100) >= 50);
|
| - milliseconds ~/= 100;
|
| - }
|
| - if (addOneMillisecond && milliseconds < 999) {
|
| - addOneMillisecond = false;
|
| - milliseconds++;
|
| - }
|
| + int milliseconds = (parseDoubleOrZero(match[7]) * 1000).round();
|
| + if (milliseconds == 1000) {
|
| + addOneMillisecond = true;
|
| + milliseconds = 999;
|
| }
|
| // TODO(floitsch): we should not need to test against the empty string.
|
| bool isUtc = (match[8] !== null) && (match[8] != "");
|
|
|