prime.js icon indicating copy to clipboard operation
prime.js copied to clipboard

changed range in datepicker to 100 years ago to current year

Open amans330 opened this issue 5 years ago • 6 comments

amans330 avatar Dec 17 '20 23:12 amans330

Hi @robotdan please review.

amans330 avatar Dec 18 '20 00:12 amans330

Can you describe the fix, what was broken and how did this fix it? Also, missing tests.

robotdan avatar Dec 18 '20 00:12 robotdan

The fix: The start year(first year in the list) was 10 years before the current year. I changed it to 100 years before the current year. The end year(last year in the list) was 10 years after the current year. I changed it to be the current year. Earlier, we couldn't select the birth year, if the user is born before 2010. No point in displaying future years as well for this use case (However, it may be required for a case like "valid till" field, which uses this datepicker widget and would need to display future years as well).

amans330 avatar Dec 18 '20 00:12 amans330

Test case added.

amans330 avatar Dec 18 '20 02:12 amans330

From a library perspective, this is just a date picker, the usage of a birthday selector is a specific use case we have in FusionAuth.

So, the ability to select a future year, while it doesn't make sense for a birthday picker, it may for other usages. I would hesitate to hard code assuming it is going to be used for a birthday picker.

So there are a few options,

  1. Change the default (this is what you have here)
  2. Change the default and provide configuration to allow it to be customized
  3. Leave the existing values, and provide configuration to allow it to be customized

Thoughts?

robotdan avatar Dec 18 '20 21:12 robotdan

Yeah, hardcoding it to show till the current year doesn't seem right to me either (last line in my previous comment). But providing configuration for start and end years sounds like overkill to me here. We can give the range from the last 100 to the next 100 years and that would solve most of the cases. Let me know what would you like to be done.

amans330 avatar Dec 21 '20 20:12 amans330