From 2004e7e90ca86f66f1bd0946d3fab8a580f0cd91 Mon Sep 17 00:00:00 2001 From: David Wright <24604124+dimwight@users.noreply.github.com> Date: Thu, 11 Nov 2021 22:18:39 +0000 Subject: [PATCH 1/3] fractionalDaysSinceEpoch --- src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java b/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java index 6699cea54..36276402a 100644 --- a/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java +++ b/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java @@ -699,7 +699,8 @@ public static Double toNumeric(Object o) { val = NaN; } } else if (o instanceof Date) { - val = (double) DateUtils.daysSinceEpoch((Date) o); + val = (double) DateUtils.fractionalDaysSinceEpoch((Date) o); + q } else if (o instanceof IExprDataType) { val = ((IExprDataType) o).toNumeric(); } From 9e598c87996f765ad77fc788ccaa834acc9f7419 Mon Sep 17 00:00:00 2001 From: David Wright <24604124+dimwight@users.noreply.github.com> Date: Thu, 11 Nov 2021 22:19:33 +0000 Subject: [PATCH 2/3] formatDateTime --- src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java b/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java index 36276402a..cc7d770fa 100644 --- a/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java +++ b/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java @@ -700,7 +700,6 @@ public static Double toNumeric(Object o) { } } else if (o instanceof Date) { val = (double) DateUtils.fractionalDaysSinceEpoch((Date) o); - q } else if (o instanceof IExprDataType) { val = ((IExprDataType) o).toNumeric(); } @@ -760,7 +759,7 @@ public static String toString(Object o) { } else if (o instanceof String) { val = (String) o; } else if (o instanceof Date) { - val = DateUtils.formatDate((Date) o, DateUtils.FORMAT_ISO8601); + val = DateUtils.formatDateTime((Date) o, DateUtils.FORMAT_ISO8601); } else if (o instanceof IExprDataType) { val = ((IExprDataType) o).toString(); } From 875e699eecf7b73760032d02e2ea03436cd72761 Mon Sep 17 00:00:00 2001 From: dimwight Date: Sat, 27 Nov 2021 19:51:37 +0000 Subject: [PATCH 3/3] XPathEvalTest --- src/test/java/org/javarosa/xpath/test/XPathEvalTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java b/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java index c354511e2..a11170b42 100644 --- a/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java +++ b/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java @@ -198,7 +198,8 @@ public void type_conversions() { testEval("string('')", ""); testEval("string(' ')", " "); testEval("string('a string')", "a string"); - testEval("string(date('1989-11-09'))", "1989-11-09"); + //For #637 + testEval("string(date('1989-11-09'))", "1989-11-09T00:00:00.000Z"); testEval("string(convertible())", null, ec, "hi"); testEval("string(inconvertible())", null, ec, new XPathTypeMismatchException()); testEval("int('100')", 100.0);