Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
(fix) Bug in Ergo JavaScript runtime for min/max over dates
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
jeromesimeon committed Jan 14, 2019
1 parent 54ae508 commit 4c9e0e1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
18 changes: 14 additions & 4 deletions backends/javascript/ergo-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,18 +582,20 @@ const minDateTime = moment("0001-01-01 00:00:00");
const maxDateTime = moment("3268-01-21 23:59:59");

function dateTimeMax(v) {
if (v.length === 0) {
var v1 = mustBeDateArray(v);
if (v1.length === 0) {
return minDateTime;
} else {
return moment.max(v);
return moment.max(v1);
}
}

function dateTimeMin(v) {
if (v.length === 0) {
var v1 = mustBeDateArray(v);
if (v1.length === 0) {
return maxDateTime;
} else {
return moment.min(v);
return moment.min(v1);
}
}

Expand Down Expand Up @@ -698,6 +700,14 @@ function mustBeDate(date) {
}
}

function mustBeDateArray(dateArray) {
var newDateArray = [];
for (var i=0; i<dateArray.length; i++) {
newDateArray.push(mustBeDate(dateArray[i]));
}
return newDateArray;
}

function mustBeDuration(d) {
if (typeof d == "string") {
return moment.duration(d);
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ergo-cli/lib/ergoc-lib.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ergo-cli/lib/ergotop-lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ergo-compiler/lib/ergo-core.js

Large diffs are not rendered by default.

0 comments on commit 4c9e0e1

Please sign in to comment.