surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.01k stars 782 forks source link

Add various utility date related expression functions #6547

Closed PerikiyoXD closed 11 months ago

PerikiyoXD commented 11 months ago

I'd like to have weekday(), year(), day(), month() functions as defaults

Are you requesting a feature, reporting a bug or asking a question?

A feature

What is the current behavior?

What is the expected behavior?

Have default expression functions for:

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

your_code_here

Specify your

PerikiyoXD commented 11 months ago

I know I can implement custom functions myself, but I think having these functions by default wouldn't hurt and would be good enough by default, since "today()" is just a raw JS date. Adding those functions would allow easy string construction for some contexts that need date handling.

PerikiyoXD commented 11 months ago

I think having these functions:

is enough to handle most date building cases.

You can suggest other names if these don't really make much sense, as probably there are better alternatives.

PerikiyoXD commented 10 months ago

Thanks for adding the requested functionality!

Although, I would like to ask one more thing on this topic. If you have a look at the commit I created that didn't make it to the PR (fafb62c), I added "names" related to dates.

I didn't clarify the reason behind the utility functions request. The end goal was to generate a string like "Monday, July 20, 2023" in an expression question.

Anyways, we got half of the requested functions. I hope you can take a look at the commit again and implement the name-related functions.

Thank you!