| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(jmesserly): the native class should be the real JS Date. | 5 // TODO(jmesserly): the native class should be the real JS Date. |
| 6 // TODO(jimhug): Making the date value non-lazy might be a good path there. | 6 // TODO(jimhug): Making the date value non-lazy might be a good path there. |
| 7 class DateImplementation implements Date { | 7 class DateImplementation implements Date { |
| 8 final int value; | 8 final int value; |
| 9 final TimeZone timeZone; | 9 final TimeZone timeZone; |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return Math.parseDouble(matched); | 70 return Math.parseDouble(matched); |
| 71 } | 71 } |
| 72 | 72 |
| 73 int years = Math.parseInt(match[1]); | 73 int years = Math.parseInt(match[1]); |
| 74 int month = Math.parseInt(match[2]); | 74 int month = Math.parseInt(match[2]); |
| 75 int day = Math.parseInt(match[3]); | 75 int day = Math.parseInt(match[3]); |
| 76 int hours = parseIntOrZero(match[4]); | 76 int hours = parseIntOrZero(match[4]); |
| 77 int minutes = parseIntOrZero(match[5]); | 77 int minutes = parseIntOrZero(match[5]); |
| 78 int seconds = parseIntOrZero(match[6]); | 78 int seconds = parseIntOrZero(match[6]); |
| 79 bool addOneMillisecond = false; | 79 bool addOneMillisecond = false; |
| 80 int milliseconds = (parseDoubleOrZero(match[7]) * 1000).round(); | 80 int milliseconds = (parseDoubleOrZero(match[7]) * 1000).round().toInt(); |
| 81 if (milliseconds == 1000) { | 81 if (milliseconds == 1000) { |
| 82 addOneMillisecond = true; | 82 addOneMillisecond = true; |
| 83 milliseconds = 999; | 83 milliseconds = 999; |
| 84 } | 84 } |
| 85 // TODO(floitsch): we should not need to test against the empty string. | 85 // TODO(floitsch): we should not need to test against the empty string. |
| 86 bool isUtc = (match[8] !== null) && (match[8] != ""); | 86 bool isUtc = (match[8] !== null) && (match[8] != ""); |
| 87 TimeZone timezone = isUtc ? const TimeZone.utc() : new TimeZone.local(); | 87 TimeZone timezone = isUtc ? const TimeZone.utc() : new TimeZone.local(); |
| 88 int epochValue = _valueFromDecomposed( | 88 int epochValue = _valueFromDecomposed( |
| 89 years, month, day, hours, minutes, seconds, milliseconds, isUtc); | 89 years, month, day, hours, minutes, seconds, milliseconds, isUtc); |
| 90 if (epochValue === null) { | 90 if (epochValue === null) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return isUtc == other.isUtc; | 275 return isUtc == other.isUtc; |
| 276 } | 276 } |
| 277 | 277 |
| 278 String toString() { | 278 String toString() { |
| 279 if (isUtc) return "TimeZone (UTC)"; | 279 if (isUtc) return "TimeZone (UTC)"; |
| 280 return "TimeZone (Local)"; | 280 return "TimeZone (Local)"; |
| 281 } | 281 } |
| 282 | 282 |
| 283 final bool isUtc; | 283 final bool isUtc; |
| 284 } | 284 } |
| OLD | NEW |