KovtunV / NoStringEvaluating

Fast low memory consuming mathematical evaluation without endless string parsing! Parses string formula once and uses its object sequence in each evaluation. Moreover, provides user defined functions and variables.
MIT License
28 stars 10 forks source link

DateTime Functions #9

Closed Atallah-Hammad closed 1 year ago

Atallah-Hammad commented 1 year ago

Hi, Are DateTime Functions working? DateDif(date1; date2; 'Y')?

If yes, Can give me an example

KovtunV commented 1 year ago

@Atallah-Hammad Hi, I believe yes, actually it should work as this but for "Y", "M", "D" only.

for example

static void Main()
{
    var eval = NoStringEvaluator.CreateFacade().Evaluator;

    var args = new Dictionary<string, EvaluatorValue>
    {
        { "date1", DateTime.Parse("01.01.2001") },
        { "date2", DateTime.Parse("01.01.2003") }
    };

    var res = eval.CalcNumber("DateDif(date1; date2; 'Y')", args); // 2
}
Atallah-Hammad commented 1 year ago

Thanks alot