Merge pull request #1606 from ostephens/issue/1588-2
Corrected spelling of Calender to Calendar
This commit is contained in:
commit
f90c7eecb8
@ -49,7 +49,7 @@ import org.json.JSONWriter;
|
||||
|
||||
import com.google.refine.expr.EvalError;
|
||||
import com.google.refine.expr.util.CalendarParserException;
|
||||
import com.google.refine.expr.util.CalenderParser;
|
||||
import com.google.refine.expr.util.CalendarParser;
|
||||
import com.google.refine.grel.ControlFunctionRegistry;
|
||||
import com.google.refine.grel.Function;
|
||||
import com.google.refine.util.ParsingUtilities;
|
||||
@ -82,7 +82,7 @@ public class ToDate implements Function {
|
||||
month_first = (Boolean) args[1];
|
||||
}
|
||||
try {
|
||||
return CalenderParser.parseAsOffsetDateTime( o1, (month_first) ? CalenderParser.MM_DD_YY : CalenderParser.DD_MM_YY);
|
||||
return CalendarParser.parseAsOffsetDateTime( o1, (month_first) ? CalendarParser.MM_DD_YY : CalendarParser.DD_MM_YY);
|
||||
} catch (CalendarParserException e) {
|
||||
OffsetDateTime d = ParsingUtilities.stringToDate(o1);
|
||||
if (d != null) {
|
||||
|
@ -494,7 +494,7 @@ class ParserState {
|
||||
/**
|
||||
* A parser for arbitrary date/time strings.
|
||||
*/
|
||||
public class CalenderParser {
|
||||
public class CalendarParser {
|
||||
/** bit indicating that the year comes before the month. */
|
||||
public static final int YEAR_BEFORE_MONTH = ParserState.YEAR_BEFORE_MONTH;
|
||||
/** bit indicating that the year comes before the day. */
|
@ -45,7 +45,7 @@ import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.expr.EvalError;
|
||||
import com.google.refine.expr.util.CalendarParserException;
|
||||
import com.google.refine.expr.util.CalenderParser;
|
||||
import com.google.refine.expr.util.CalendarParser;
|
||||
import com.google.refine.grel.ControlFunctionRegistry;
|
||||
import com.google.refine.grel.Function;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
@ -118,19 +118,19 @@ public class ToFromConversionTests extends RefineTest {
|
||||
Assert.assertEquals(invoke("toString", Double.valueOf(100.0),"%.0f"),"100");
|
||||
|
||||
String inputDate = "2013-06-01";
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate)),
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDate)),
|
||||
"01-Jun-2013");
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy-MM-dd"),
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDate), "yyyy-MM-dd"),
|
||||
"2013-06-01");
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy/dd/MM"), "2013/01/06");
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy-MMM"), "2013-Jun");
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDate), "yyyy-MM-dd hh:mm:ss"), "2013-06-01 12:00:00");
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDate), "yyyy/dd/MM"), "2013/01/06");
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDate), "yyyy-MMM"), "2013-Jun");
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDate), "yyyy-MM-dd hh:mm:ss"), "2013-06-01 12:00:00");
|
||||
|
||||
String inputDateTime = "2013-06-01 13:12:11";
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime)), "01-Jun-2013");
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd"), "2013-06-01");
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd hh:mm:ss"),"2013-06-01 01:12:11");
|
||||
Assert.assertEquals(invoke("toString", CalenderParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd HH:mm:ss"),"2013-06-01 13:12:11");
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDateTime)), "01-Jun-2013");
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd"), "2013-06-01");
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd hh:mm:ss"),"2013-06-01 01:12:11");
|
||||
Assert.assertEquals(invoke("toString", CalendarParser.parseAsOffsetDateTime(inputDateTime), "yyyy-MM-dd HH:mm:ss"),"2013-06-01 13:12:11");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -141,15 +141,15 @@ public class ToFromConversionTests extends RefineTest {
|
||||
Assert.assertTrue(invoke("toDate", 1.0) instanceof EvalError);
|
||||
Assert.assertTrue(invoke("toDate", "2012-03-01","xxx") instanceof EvalError); // bad format string
|
||||
Assert.assertTrue(invoke("toDate", "2012-03-01") instanceof OffsetDateTime);
|
||||
Assert.assertEquals(invoke("toDate", "2012-03-01"),CalenderParser.parseAsOffsetDateTime("2012-03-01"));
|
||||
Assert.assertEquals(invoke("toDate", "2012-03-01","yyyy-MM-dd"),CalenderParser.parseAsOffsetDateTime("2012-03-01"));
|
||||
Assert.assertEquals(invoke("toDate", "2012-03-01"),CalendarParser.parseAsOffsetDateTime("2012-03-01"));
|
||||
Assert.assertEquals(invoke("toDate", "2012-03-01","yyyy-MM-dd"),CalendarParser.parseAsOffsetDateTime("2012-03-01"));
|
||||
|
||||
// Multiple format strings should get tried sequentially until one succeeds or all are exhausted
|
||||
Assert.assertEquals(invoke("toDate", "2012-03-01","MMM","yyyy-MM-dd"), CalenderParser.parseAsOffsetDateTime("2012-03-01"));
|
||||
Assert.assertEquals(invoke("toDate", "2012-03-01","MMM","yyyy-MM-dd"), CalendarParser.parseAsOffsetDateTime("2012-03-01"));
|
||||
|
||||
// First string can be a locale identifier instead of a format string
|
||||
Assert.assertEquals(invoke("toDate", "2013-06-01","zh"), CalenderParser.parseAsOffsetDateTime("2013-06-01"));
|
||||
Assert.assertEquals(invoke("toDate", "01-六月-2013","zh","dd-MMM-yyyy"), CalenderParser.parseAsOffsetDateTime("2013-06-01"));
|
||||
Assert.assertEquals(invoke("toDate", "2013-06-01","zh"), CalendarParser.parseAsOffsetDateTime("2013-06-01"));
|
||||
Assert.assertEquals(invoke("toDate", "01-六月-2013","zh","dd-MMM-yyyy"), CalendarParser.parseAsOffsetDateTime("2013-06-01"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user