wakirin / Litepicker

Date range picker - lightweight, no dependencies
MIT License
898 stars 132 forks source link

Jalali Calendar #161

Closed MR-Mostafa closed 3 years ago

MR-Mostafa commented 3 years ago

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like Hello Is any way to your datepicker support jalali calendar (Persian Calendar)? For logic difference between these dates(jalali & gregorian) you can use: Persian Date OR jalaali-js Thanks

wakirin commented 3 years ago

Perhaps v2 can help here (currently in beta).

https://jsfiddle.net/Le5f2zvb/

I don't know if this displays correctly, but I hope you can find a way to adapt it.

MR-Mostafa commented 3 years ago

Perhaps v2 can help here (currently in beta). https://jsfiddle.net/Le5f2zvb/ I don't know if this displays correctly, but I hope you can find a way to adapt it.

Thanks a lot, it's almost ok, but there are some problems: 1) In Jalali (solar) date, the first day of the week is Saturday (fixed with firstDay: 6 property). 2) Shows the year incorrectly (shows in Gregorian calendar, not solar) 3) The days of the month are displayed correctlym, but the first day of the month does not separate from the previous month in view (ui).

4) When we select a date range it does not display correctly in the input.

MR-Mostafa commented 3 years ago

@wakirin The fourth problem was solved by changing the following code:

output(date) {
    return new persianDate(date).format("dddd, ha");
}
output(date) {
    return new persianDate(date).format("YYYY/M/D");
}
wakirin commented 3 years ago

https://jsfiddle.net/txc40ehj/

This should fix 2 and 3. Not sure if I got it right about 3.

MR-Mostafa commented 3 years ago

@wakirin No, the problem is not solved. When we change the months, the year 1399 is still displayed and does not change to the next year. I'm trying to solve the problem of the year, but I have no idea how to show the days. (The third problem)

wakirin commented 3 years ago

Try to replace: el.innerHTML = ' ' + new persianDate(year).format('YYYY'); to el.innerHTML = ' ' + new persianDate([year]).format('YYYY');

I don't understand very well about problem 3. Could you show the expected result ?

MR-Mostafa commented 3 years ago

@wakirin For the third problem, I mean that each month should start from the beginning of the same month (solar month) and not from the continuation of the previous month (Gregorian month). 5.jpg

In short: I mean the days of each month (solar month) should be displayed in the same month and in the same column

wakirin commented 3 years ago

Currently, only the Gregorian months are displayed in the calendar. You can try change this behavior with v2 beta.5 using .on('render:month', (month, date) => {..}); for the render days, which is what you want.

wakirin commented 3 years ago

@MR-Mostafa I prepared a new example with v2 and plugin.

https://dev.lvl.ninja/litepicker/jalali.html

Currently some options may have not work (like lockDays, minDate, maxDate, etc)

atiyehahmadi commented 3 years ago

Hi, Years is displayed Wrong. it should be 1400 when we using lang:"fa".

Capture

MR-Mostafa commented 3 years ago

Hi Sorry, no news for the new plugin of jalali calendar? @wakirin