T00rk / bootstrap-material-datetimepicker

Datepicker for bootstrap-material
http://t00rk.github.io/bootstrap-material-datetimepicker/
MIT License
8 stars 4 forks source link

please add persian calendar #102

Open saeedvir opened 8 years ago

saeedvir commented 8 years ago

please add persian calendar

http://babakhani.github.io/PersianWebToolkit/doc/datepicker/0.4.5/

sujoyu commented 8 years ago

It is not enough with the following settings?

$("datepicker").bootstrapMaterialDatePicker({
      lang: "fa"
});

bootstrap-material-datetimepicker uses moment.js's locale. http://momentjs.com/

hrsh commented 5 years ago

lang: "fa" just change appearance of months and days names. How do i change to persian calendar?

sujoyu commented 5 years ago

Sorry, I was wrong. I think following probably works.

First, load https://github.com/fingerpich/jalali-moment instead of moment.js.

Now, global variable moment is jalali-moment.

And initialize locale fa.

$(".datepicker").bootstrapMaterialDatePicker({
      lang: "fa"
});

When jalali-moment set locale to fa, jalali-moment uses persian calendar system.

hrsh commented 5 years ago

Thanks. That works fine. But now, I have to problems:

  1. Short day names render as I.
  2. Numbers shown in english format. for example 1397 instead of ۱۳۹۷ Preview would you please help me?
alisalmani commented 5 years ago

i =invalid date in line 734 find for (var ii = 0; ii < calendar.week.length; ii++) { _template += '<th>' + moment(parseInt(calendar.week[ii]), "d").locale(this.params.lang).format("dd").substring(0, 1) + '</th>'; } and comment it and add static code: _template += '<th>' + 'ش' + '</th>'; _template += '<th>' + 'ی' + '</th>'; _template += '<th>' + 'د' + '</th>'; _template += '<th>' + 'س' + '</th>'; _template += '<th>' + 'چ' + '</th>'; _template += '<th>' + 'پ' + '</th>'; _template += '<th>' + 'ج' + '</th>';

and in init : weekStart=6