| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of html; | 5 part of html; |
| 6 | 6 |
| 7 class _Utils { | 7 class _Utils { |
| 8 static double dateTimeToDouble(DateTime dateTime) => | 8 static double dateTimeToDouble(DateTime dateTime) => |
| 9 dateTime.millisecondsSinceEpoch.toDouble(); | 9 dateTime.millisecondsSinceEpoch.toDouble(); |
| 10 static DateTime doubleToDateTime(double dateTime) => | 10 static DateTime doubleToDateTime(double dateTime) { |
| 11 new DateTime.fromMillisecondsSinceEpoch(dateTime.toInt()); | 11 try { |
| 12 return new DateTime.fromMillisecondsSinceEpoch(dateTime.toInt()); |
| 13 } catch { |
| 14 // TODO(antonnm): treat exceptions properly in bindings and |
| 15 // find out how to treat NaNs. |
| 16 return null; |
| 17 } |
| 18 } |
| 12 | 19 |
| 13 static List convertToList(List list) { | 20 static List convertToList(List list) { |
| 14 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is
fine w/ it. | 21 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is
fine w/ it. |
| 15 final length = list.length; | 22 final length = list.length; |
| 16 List result = new List(length); | 23 List result = new List(length); |
| 17 result.setRange(0, length, list); | 24 result.setRange(0, length, list); |
| 18 return result; | 25 return result; |
| 19 } | 26 } |
| 20 | 27 |
| 21 static List convertMapToList(Map map) { | 28 static List convertMapToList(Map map) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 bool get isEmpty => Maps.isEmpty(this); | 119 bool get isEmpty => Maps.isEmpty(this); |
| 113 } | 120 } |
| 114 | 121 |
| 115 get _printClosure => (s) { | 122 get _printClosure => (s) { |
| 116 try { | 123 try { |
| 117 window.console.log(s); | 124 window.console.log(s); |
| 118 } catch (_) { | 125 } catch (_) { |
| 119 _Utils.print(s); | 126 _Utils.print(s); |
| 120 } | 127 } |
| 121 }; | 128 }; |
| OLD | NEW |