Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for #637 Validation of dateTime widget… #652

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ 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);
} else if (o instanceof IExprDataType) {
val = ((IExprDataType) o).toNumeric();
}
Expand Down Expand Up @@ -759,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();
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/javarosa/xpath/test/XPathEvalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down