Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow date data types? #13

Open
ghost opened this issue May 18, 2016 · 2 comments
Open

Allow date data types? #13

ghost opened this issue May 18, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented May 18, 2016

I need your library for parsing expressions but I saw that it only supports numbers and strings.
Is it possible to somehow allow date manipulation?
The expression I need to parse is:

'31.07.' + (myDate.getMonth() <= 7 ? myDate.getFullYear() + 3: myDate.getFullYear() + 4 )

@cshaa
Copy link
Contributor

cshaa commented May 2, 2018

You can define your custom functions for it:

let filter = compileExpression(
  '"31.07." + (month(myDate) <= 7 ? year(myDate) + 3 : year(myDate) + 4)',
  {
    month: date => date.getMonth(),
    year: date => date.getFullYear()
  }
);

filter({myDate: new Date()});

@cshaa
Copy link
Contributor

cshaa commented Feb 24, 2019

@joewalnes Close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant