angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.34k stars 6.74k forks source link

DatePicker bug, when using 'fa' value for MAT_DATE_LOCALE #13332

Closed hapoo44 closed 6 years ago

hapoo44 commented 6 years ago

Bug, feature request, or proposal:

this is a bug, when you inject MAT_DATE_LOCALE by 'fa' value, the datepicker calendar shows incorrect days for each month. incorrect means exactly each day number is added by 3. so if today is 5th day of month, calendar shows 8 and if tomorrow is 6th day of month, calendar shows 9. and if you select today which calendar show as 8, the correct number placed in date input. that means 5 is placed in date input .

What is the expected behavior?

the expected behavior is calendar must show every day number minus 3.

What is the current behavior?

the current behavior is calendar add 3 to each day number. that mean today is 5th day of month but calendar shows 8. and when you select 8, in date input correct day number (5) is placed.

What are the steps to reproduce?

just put { provide: MAT_DATE_LOCALE, useValue: 'fa-IR' } in app module providers and if you know jalali or persian calendar, you can see the bug and if you don't know this calendar, just select one day in calendar and you see the selected date day number in input is 3 less than day selected in calendar. the input is correct and the calendar is incorrect.

What is the use-case or motivation for changing an existing behavior?

it's a jalali calendar. the most accurate solar calendar in world and used by four and more country in the world.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

i test it with angular 6.0.2 and material 6.0.2 and material 6.4.7. and both of them had that bug

Is there anything else we should know?

if anyone help what code show's days in calendar , i can solve it.

hapoo44 commented 6 years ago

i think the bug is because the calendar shows the number of days for gregorian month, that means some jalali month is 31 day's, some 30 day's and one 29 day's. and calendar shows day's for gregorian month that means if the jalali month is 31 day's and gregorian month is 30 day's that bug occur. but when you select the day, the selected date is correct

jelbourn commented 6 years ago

@mmalerba the datepicker only supports the gregorian calendar, right?

mmalerba commented 6 years ago

Yes, out of the box we only support Gregorian, though I have seen people post that they've been able to create adapters for the Jalali calendar. See https://github.com/angular/material2/issues/5972 and https://github.com/angular/material2/issues/2519

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.