Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: tools/dom/src/native_DOMImplementation.dart

Issue 12493011: Make sure double to DateTime conversion never throws. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/native_DOMImplementation.dart
diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart
index cd98baf128b56e9773769fd923b8b643330dcc8d..82124d85ab9ebcc3bef92f747409e91f8cff71e2 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -7,8 +7,15 @@ part of html;
class _Utils {
static double dateTimeToDouble(DateTime dateTime) =>
dateTime.millisecondsSinceEpoch.toDouble();
- static DateTime doubleToDateTime(double dateTime) =>
- new DateTime.fromMillisecondsSinceEpoch(dateTime.toInt());
+ static DateTime doubleToDateTime(double dateTime) {
+ try {
+ return new DateTime.fromMillisecondsSinceEpoch(dateTime.toInt());
+ } catch {
+ // TODO(antonnm): treat exceptions properly in bindings and
+ // find out how to treat NaNs.
+ return null;
+ }
+ }
static List convertToList(List list) {
// FIXME: [possible optimization]: do not copy the array if Dart_IsArray is fine w/ it.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698