From ebede9b424bf39dbc1be8eb7be2b1584136f8be9 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Tue, 13 Sep 2011 20:58:43 +0000 Subject: [PATCH] Issue 441 - return EvalError if we can't parse a date git-svn-id: http://google-refine.googlecode.com/svn/trunk@2237 7d457c2a-affb-35e4-300a-418c747d4874 --- main/src/com/google/refine/expr/functions/ToDate.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main/src/com/google/refine/expr/functions/ToDate.java b/main/src/com/google/refine/expr/functions/ToDate.java index 1058441d1..603e82fb8 100644 --- a/main/src/com/google/refine/expr/functions/ToDate.java +++ b/main/src/com/google/refine/expr/functions/ToDate.java @@ -1,6 +1,6 @@ /* -Copyright 2010, Google Inc. +Copyright 2010,2011. Google Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ import java.util.Properties; import org.json.JSONException; import org.json.JSONWriter; +import com.google.refine.expr.EvalError; import com.google.refine.expr.util.CalendarParser; import com.google.refine.expr.util.CalendarParserException; import com.google.refine.grel.Function; @@ -61,7 +62,7 @@ public class ToDate implements Function { return ((Calendar) arg0).getTime(); } else if (!(arg0 instanceof String)) { // ignore cell values that aren't strings - return null; + return new EvalError("Not a String - cannot parse to date"); } String o1 = (String) arg0; @@ -74,7 +75,7 @@ public class ToDate implements Function { try { return CalendarParser.parse( o1, (month_first) ? CalendarParser.MM_DD_YY : CalendarParser.DD_MM_YY); } catch (CalendarParserException e) { - // do something about + return new EvalError("Cannot parse to date"); } } @@ -91,7 +92,7 @@ public class ToDate implements Function { try { date = formatter.parse(o1); } catch (java.text.ParseException e) { - // ignore + return new EvalError("Cannot parse to date"); } if (date != null) { GregorianCalendar c = new GregorianCalendar();