| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart._js_helper; | 5 library dart._js_helper; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'dart:_foreign_helper' show | 9 import 'dart:_foreign_helper' show |
| 10 JS, | 10 JS, |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 match = JS('JSArray|Null', r'/(?:GMT|UTC)[+-]\d{4}/.exec(#.toString())', d); | 353 match = JS('JSArray|Null', r'/(?:GMT|UTC)[+-]\d{4}/.exec(#.toString())', d); |
| 354 if (match != null) return match[0]; | 354 if (match != null) return match[0]; |
| 355 return ""; | 355 return ""; |
| 356 } | 356 } |
| 357 | 357 |
| 358 static int getTimeZoneOffsetInMinutes(DateTime receiver) { | 358 static int getTimeZoneOffsetInMinutes(DateTime receiver) { |
| 359 // Note that JS and Dart disagree on the sign of the offset. | 359 // Note that JS and Dart disagree on the sign of the offset. |
| 360 return -JS('int', r'#.getTimezoneOffset()', lazyAsJsDate(receiver)); | 360 return -JS('int', r'#.getTimezoneOffset()', lazyAsJsDate(receiver)); |
| 361 } | 361 } |
| 362 | 362 |
| 363 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds, | 363 static num valueFromDecomposedDate(int years, int month, int day, int hours, |
| 364 milliseconds, isUtc) { | 364 int minutes, int seconds, int milliseconds, bool isUtc) { |
| 365 final int MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; | 365 final int MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; |
| 366 checkInt(years); | 366 checkInt(years); |
| 367 checkInt(month); | 367 checkInt(month); |
| 368 checkInt(day); | 368 checkInt(day); |
| 369 checkInt(hours); | 369 checkInt(hours); |
| 370 checkInt(minutes); | 370 checkInt(minutes); |
| 371 checkInt(seconds); | 371 checkInt(seconds); |
| 372 checkInt(milliseconds); | 372 checkInt(milliseconds); |
| 373 checkBool(isUtc); | 373 checkBool(isUtc); |
| 374 var jsMonth = month - 1; | 374 var jsMonth = month - 1; |
| 375 var value; | 375 num value; |
| 376 if (isUtc) { | 376 if (isUtc) { |
| 377 value = JS('num', r'Date.UTC(#, #, #, #, #, #, #)', | 377 value = JS('num', r'Date.UTC(#, #, #, #, #, #, #)', |
| 378 years, jsMonth, day, hours, minutes, seconds, milliseconds); | 378 years, jsMonth, day, hours, minutes, seconds, milliseconds); |
| 379 } else { | 379 } else { |
| 380 value = JS('num', r'new Date(#, #, #, #, #, #, #).valueOf()', | 380 value = JS('num', r'new Date(#, #, #, #, #, #, #).valueOf()', |
| 381 years, jsMonth, day, hours, minutes, seconds, milliseconds); | 381 years, jsMonth, day, hours, minutes, seconds, milliseconds); |
| 382 } | 382 } |
| 383 if (value.isNaN || | 383 if (value.isNaN || |
| 384 value < -MAX_MILLISECONDS_SINCE_EPOCH || | 384 value < -MAX_MILLISECONDS_SINCE_EPOCH || |
| 385 value > MAX_MILLISECONDS_SINCE_EPOCH) { | 385 value > MAX_MILLISECONDS_SINCE_EPOCH) { |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 // we have no way of telling the compiler yet, so it will generate an extra | 864 // we have no way of telling the compiler yet, so it will generate an extra |
| 865 // layer of indirection that wraps the SyncIterator. | 865 // layer of indirection that wraps the SyncIterator. |
| 866 _jsIterator() => JS('', '#(...#)', _generator, _args); | 866 _jsIterator() => JS('', '#(...#)', _generator, _args); |
| 867 | 867 |
| 868 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); | 868 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); |
| 869 } | 869 } |
| 870 | 870 |
| 871 class BooleanConversionAssertionError extends AssertionError { | 871 class BooleanConversionAssertionError extends AssertionError { |
| 872 toString() => 'Failed assertion: boolean expression must not be null'; | 872 toString() => 'Failed assertion: boolean expression must not be null'; |
| 873 } | 873 } |
| OLD | NEW |