EdgeVerve / feel

Expression Language for creating and executing business rules in decision table based on DMN 1.1 specification for conformance level 3
MIT License
93 stars 48 forks source link

date_and_time isn't working as expected in execute_decision_table #1

Closed thaukap closed 7 years ago

thaukap commented 7 years ago

Hi everybody!

We're using js-feel for a week now but struggling in using date_and_time as payload. Here is a simple example code sniped, which should return the result "is greater" because 2018-06-09 is a greater date than 2017-06-08. But it doesn't it always returns "default", means no match.

So what's wrong here:

it("evaluate js feel with examples for date", function (done) {
    let payload = {
        inputDate: Date.parse("2018-06-09T00:00:00Z")
    };

    let decisionTable = {
        hitPolicy: 'U',
        inputExpressionList: ['inputDate'],
        outputs: ['ComparedDatesResult'],
        inputValuesList:
        ['> date_and_time("2017-06-09T00:00:00Z"),< date_and_time("2017-06-09T00:00:00Z"),-'],
        outputValues: [['"is greater"', '"is less"', '"default"']],
        ruleList:
        [
            ['> date_and_time("2017-06-09T00:00:00Z")', '"is greater"'],
            ['< date_and_time("2017-06-09T00:00:00Z")', '"is less"'],
            ['-', '"default"']
        ],
        context: null
    };

    jsFeel.decisionTable.execute_decision_table("test table with date", decisionTable, payload, (err, results) => {
        console.log(results);
        done();
    });
});
SambitKumarPatra commented 7 years ago

Date and time functionalities has not been implemented. Those features will be available in next release(somewhat around end of July, 2017).

raghav135 commented 7 years ago

+1

gustavomick commented 7 years ago

hi!, nice work. have you included date ranges as part of this release? like [date and time("2017-04-12T13:30:00.000Z")...date and time("2017-04-12T12:45:00.000Z")]

pragyandas commented 7 years ago

@gustavomick Thanks. It is just a literal and can be used just like any literal. So for your question, range would absolutely work.

gustavomick commented 7 years ago

@pragyandas oh thanks, i tried with current version and is not working yet, i think is failing with 3dots token. number range is working thou.

pragyandas commented 7 years ago

@gustavomick This is WIP and will be included in the next release 😄

pragyandas commented 7 years ago

@gustavomick I have added 'date and time range' feature. The below expression (comparision expression in DMN FEEL grammar) works now.

date and time("2017-04-12T11:45:00Z") in [date and time("2017-04-12T11:30:00Z")..date and time("2017-04-12T12:45:00Z")]

A few things worth mentioning here ;

All the date and time features will be made available as part of js-feel@1.2.0 release.

gustavomick commented 7 years ago

@pragyandas nice thanks.

regarding ms not working thats odd!

pragyandas commented 7 years ago

@gustavomick I completely agree with you on that. The DMN 1.1 documentation doesn't mention anything regarding ms 😞

pragyandas commented 7 years ago

date, time, date and time and duration added. Please refer Date-Time-Support wiki for more information.