diff --git a/lib/condition/condition.ts b/lib/condition/condition.ts index ccd9a7c..557bc9b 100644 --- a/lib/condition/condition.ts +++ b/lib/condition/condition.ts @@ -113,8 +113,8 @@ export class Range { ); if (between) { this.min = between.min; - this.max = between.max; this.eqMin = true; + this.max = between.max; this.eqMax = false; } return; @@ -161,10 +161,14 @@ export class Range { this.defaultTimezone, ); if (between) { - this.min = between.min; - this.eqMin = true; - this.max = between.max; - this.eqMax = false; + if (this.min === undefined || between.min < this.min) { + this.min = between.min; + this.eqMin = true; + } + if (this.max === undefined || between.max < this.max) { + this.max = between.max; + this.eqMax = false; + } } return; } diff --git a/lib/strategy/ordered.ts b/lib/strategy/ordered.ts index c19565e..0dad407 100644 --- a/lib/strategy/ordered.ts +++ b/lib/strategy/ordered.ts @@ -316,22 +316,13 @@ export class OrderedStrategy { if (x.termType === "Literal") { dataType = x.datatype.value; } - console.log( - "Found inbetween relation", - x.value, - undefined, - "Z", - ); const between = parseInBetweenRelation(x.value, dataType, "Z"); - console.log("result", between); if (between) { return [between]; } return []; }); - console.log("betweens", betweens); - if (this.ordered === "ascending") { value = betweens .map((x) => x.min) @@ -359,8 +350,6 @@ export class OrderedStrategy { }, value); } - console.log("value from inbetweens", value); - if (this.ordered === "ascending") { value = rel.relations .filter((x) => GTRs.some((gr) => x.type.value === gr.value)) @@ -444,13 +433,6 @@ export class OrderedStrategy { } // Actually emit some members in order - console.log( - "marker", - head.source, - head.target, - marker.important, - marker.value, - ); if (marker.important) { found.closed = true; let member = this.members.pop(); diff --git a/lib/utils/inBetween.ts b/lib/utils/inBetween.ts index a947860..4b235b6 100644 --- a/lib/utils/inBetween.ts +++ b/lib/utils/inBetween.ts @@ -12,42 +12,27 @@ export function parseInBetweenRelation( dataType: string | undefined, defaultTimezone: string, ): Between | undefined { - let thisMin: Date | undefined; - let thisMax: Date | undefined; - - const updateResult = (min: Date, max: Date) => { - if (thisMin === undefined || min <= thisMin) { - thisMin = min; - } - if (thisMax === undefined || max > thisMax) { - thisMax = max; - } - }; - if (dataType === XSD.custom("gYear")) { const result = gYearToMinMax(value, defaultTimezone); if (!result) return; const [min, max] = result; - updateResult(min, max); + return { min, max }; } else if (dataType === XSD.custom("gYearMonth")) { const result = gYearMonthToMinMax(value, defaultTimezone); if (!result) return; const [min, max] = result; - updateResult(min, max); + return { min, max }; } else if (dataType === XSD.custom("date")) { const result = dateToMinMax(value, defaultTimezone); if (!result) return; const [min, max] = result; - updateResult(min, max); + return { min, max }; } else { // Check if it is a partial dateTime const result = partialDateTimeToMinMax(value, defaultTimezone); if (!result) return; const [min, max] = result; - updateResult(min, max); - } - if (thisMin !== undefined && thisMax !== undefined) { - return { min: thisMin, max: thisMax }; + return { min, max }; } }