-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Defining week number as a function #912
Comments
Could your provide more info about your use case. The primary intention of this widget is a date selection. Why you need week numbers? You can calculate week number of selected date outside, I think. |
Can you give a concrete use case for needing a function, as opposed to just specifying a new start-of-the-week day? Any function that doesn't behave in that way would produce unpredictable layout behavior in the datepicker when showing the week number. |
At the organisation I am working for the How this is decided is based on complex logic that is roughly which week is the first to have more than 3 days in the new calendar year. A rule I have seen at another organisations is week 1 starts the first Monday after Christmas |
If this seems a reasonable parameter to extract I can make a PR? |
Some companies that deal with scheduling events do have unorthodox week numbering systems that can increase the number of weeks in an year or decrease, positioning the next year's 1st week before and ahead the ISO standard. Also, such prop could be useful for situations like fiscal year starting in April, for example. |
Sure, if you suggest a PR with some possible solution than we can take a look to see if we think it's a worthy addition. |
Hello, please find the PR below. All the best. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
A lot of big enterprises have their own week numbering system. I would like to be able provide a function as prop for calculating the current week number following that company's business logic.
The week numbers used in react-datepicker come from moment. The way to change how they are calculated in moment is to define a custom locales. There are a couple of problems with this 1) its not really a /locale/ we're talking about here 2) Custom locales only allow you to define the first day of the year as a fixed integer, which isn't enough to represent the logic that I need for determining the week number.
Instead I would like to passing a function as prop to DatePicker that calculates the week number. I can understand that you may want avoid doing this to keep moment handling the date domain. At the same time I think this is probably a fairly common use case so it would be great to see it supported in react-datepicker. What do you think? If you're happy with the idea in principle I'm happy to work up a PR.
The text was updated successfully, but these errors were encountered: