Fix Wikidata date parsing tests
This commit is contained in:
parent
5534e84b29
commit
b157651e9e
@ -54,7 +54,7 @@ public class WbDateVariable extends WbVariableExpr<TimeValue> {
|
|||||||
public TimeValue fromCell(Cell cell, ExpressionContext ctxt)
|
public TimeValue fromCell(Cell cell, ExpressionContext ctxt)
|
||||||
throws SkipSchemaExpressionException {
|
throws SkipSchemaExpressionException {
|
||||||
try {
|
try {
|
||||||
// TODO accept parsed dates (without converting them to strings)
|
// parsed dates are accepted by converting them to strings
|
||||||
return WbDateConstant.parse(cell.value.toString());
|
return WbDateConstant.parse(cell.value.toString());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
if(!cell.value.toString().isEmpty()) {
|
if(!cell.value.toString().isEmpty()) {
|
||||||
|
@ -38,6 +38,7 @@ public class WbDateConstantTest extends WbExpressionTest<TimeValue> {
|
|||||||
private WbDateConstant day = new WbDateConstant("2018-02-27");
|
private WbDateConstant day = new WbDateConstant("2018-02-27");
|
||||||
private WbDateConstant whitespace = new WbDateConstant(" 2018-02-27 ");
|
private WbDateConstant whitespace = new WbDateConstant(" 2018-02-27 ");
|
||||||
private WbDateConstant second = new WbDateConstant("2017-01-03T04:12:45");
|
private WbDateConstant second = new WbDateConstant("2017-01-03T04:12:45");
|
||||||
|
private WbDateConstant secondz = new WbDateConstant("2017-01-03T04:12:45Z");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize() {
|
public void testSerialize() {
|
||||||
@ -64,6 +65,8 @@ public class WbDateConstantTest extends WbExpressionTest<TimeValue> {
|
|||||||
TimeValue.CM_GREGORIAN_PRO), day);
|
TimeValue.CM_GREGORIAN_PRO), day);
|
||||||
evaluatesTo(Datamodel.makeTimeValue(2017, (byte) 1, (byte) 3, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0,
|
evaluatesTo(Datamodel.makeTimeValue(2017, (byte) 1, (byte) 3, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0,
|
||||||
TimeValue.CM_GREGORIAN_PRO), second);
|
TimeValue.CM_GREGORIAN_PRO), second);
|
||||||
|
evaluatesTo(Datamodel.makeTimeValue(2017, (byte) 1, (byte) 3, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0,
|
||||||
|
TimeValue.CM_GREGORIAN_PRO), secondz);
|
||||||
|
|
||||||
evaluatesTo(Datamodel.makeTimeValue(2018, (byte) 2, (byte) 27, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0,
|
evaluatesTo(Datamodel.makeTimeValue(2018, (byte) 2, (byte) 27, (byte) 0, (byte) 0, (byte) 0, (byte) 11, 0, 0, 0,
|
||||||
TimeValue.CM_GREGORIAN_PRO), whitespace);
|
TimeValue.CM_GREGORIAN_PRO), whitespace);
|
||||||
@ -76,7 +79,6 @@ public class WbDateConstantTest extends WbExpressionTest<TimeValue> {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPartlyValid() {
|
public void testPartlyValid() {
|
||||||
evaluatesTo(Datamodel.makeTimeValue(2018, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 9, 0, 0, 0,
|
isSkipped(new WbDateConstant("2018-partly valid"));
|
||||||
TimeValue.CM_GREGORIAN_PRO), new WbDateConstant("2018-partly valid"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user