fixed comparisions, accounting for multiple inversions in the code

This commit is contained in:
csoler 2023-01-17 22:33:07 +01:00
parent b87e450207
commit ffe76f03a2

View file

@ -152,24 +152,29 @@ RsRegularExpression::Expression* ExpressionWidget::getRsExpression()
case DateSearch: case DateSearch:
switch(exprCondElem->getRelOperator()) // we need to convert expressions so that the delta is 1 day (i.e. 86400 secs) switch(exprCondElem->getRelOperator()) // we need to convert expressions so that the delta is 1 day (i.e. 86400 secs)
{ {
// The conditions below account for 3 things:
// - the swap between variables in rsexpr.cc
// - the swap of variables when calling getRelOperator()
// - the fact that the "...or Equal" for days adds 86400 seconds.
default:
case RsRegularExpression::Equals: case RsRegularExpression::Equals:
expr = new RsRegularExpression::DateExpression(RsRegularExpression::InRange, checkedConversion(exprParamElem->getIntValue()), checkedConversion(86400+exprParamElem->getIntValue())); expr = new RsRegularExpression::DateExpression(RsRegularExpression::InRange, checkedConversion(exprParamElem->getIntValue()), checkedConversion(86400+exprParamElem->getIntValue()));
break; break;
case RsRegularExpression::InRange: case RsRegularExpression::InRange:
expr = new RsRegularExpression::DateExpression(exprCondElem->getRelOperator(), checkedConversion(lowVal), 86400+checkedConversion(highVal)); expr = new RsRegularExpression::DateExpression(RsRegularExpression::InRange, checkedConversion(lowVal), 86400+checkedConversion(highVal));
break; break;
case RsRegularExpression::Greater: case RsRegularExpression::Greater: // means we expect file.date() < some day D. So file.date() < D, meaning Exp=Greater
expr = new RsRegularExpression::DateExpression(RsRegularExpression::DateExpression(RsRegularExpression::SmallerEquals,checkedConversion(86400+exprParamElem->getIntValue()))); expr = new RsRegularExpression::DateExpression(RsRegularExpression::Greater,checkedConversion(exprParamElem->getIntValue()));
break; break;
case RsRegularExpression::SmallerEquals: case RsRegularExpression::SmallerEquals: // means we expect file.date() >= some day D. So file.date() >= D, meaning Exp=SmallerEquals
expr = new RsRegularExpression::DateExpression(RsRegularExpression::DateExpression(RsRegularExpression::Greater,checkedConversion(86400+exprParamElem->getIntValue()))); expr = new RsRegularExpression::DateExpression(RsRegularExpression::SmallerEquals,checkedConversion(exprParamElem->getIntValue()));
break; break;
default: case RsRegularExpression::Smaller: // means we expect file.date() > some day D. So file.date() >= D+86400, meaning Exp=SmallerEquals
case RsRegularExpression::GreaterEquals: expr = new RsRegularExpression::DateExpression(RsRegularExpression::SmallerEquals, checkedConversion(86400+exprParamElem->getIntValue()-1));
expr = new RsRegularExpression::DateExpression(RsRegularExpression::SmallerEquals, checkedConversion(exprParamElem->getIntValue()));
break; break;
case RsRegularExpression::Smaller: case RsRegularExpression::GreaterEquals: // means we expect file.date() <= some day D. So file.date() < D+86400, meaning Exp=Greater
expr = new RsRegularExpression::DateExpression(RsRegularExpression::Greater, checkedConversion(exprParamElem->getIntValue()-1)); expr = new RsRegularExpression::DateExpression(RsRegularExpression::Greater, checkedConversion(86400+exprParamElem->getIntValue()));
break; break;
} }
break; break;