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

Add various utility date related expression functions #6547

Closed
PerikiyoXD opened this issue Jul 19, 2023 · 3 comments · Fixed by #6618
Closed

Add various utility date related expression functions #6547

PerikiyoXD opened this issue Jul 19, 2023 · 3 comments · Fixed by #6618
Assignees
Labels
enhancement user issue An issue or bug reported by users
Milestone

Comments

@PerikiyoXD
Copy link

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:

  • Year: year() -> '2023'
  • Day Number: day() -> '19'
  • Month: month() -> 'January'
  • Week Day: weekday() -> 'Monday'

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

  • browser:
  • browser version:
  • surveyjs platform (angular or react or jquery or knockout or vue):
  • surveyjs version:
@PerikiyoXD
Copy link
Author

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.

@andrewtelnov andrewtelnov added enhancement user issue An issue or bug reported by users labels Jul 19, 2023
PerikiyoXD added a commit to PerikiyoXD/survey-library that referenced this issue Jul 23, 2023
Add month name, week day name and month day number functions
@PerikiyoXD
Copy link
Author

I think having these functions:

  • currentMonthName
  • currentDayName
  • currentDay

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.

@tsv2013 tsv2013 self-assigned this Jul 26, 2023
tsv2013 added a commit that referenced this issue Jul 28, 2023
andrewtelnov added a commit that referenced this issue Aug 1, 2023
Resolved #6547 - Add various utility date related expression functions
@OlgaLarina OlgaLarina added this to the v1.9.101 milestone Aug 1, 2023
@PerikiyoXD
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement user issue An issue or bug reported by users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants