mymth / vanillajs-datepicker

A vanilla JavaScript remake of bootstrap-datepicker for Bulma and other CSS frameworks
MIT License
718 stars 147 forks source link

Persian Hijri calendar (Farsi) #126

Open wpV2rayNG opened 1 year ago

wpV2rayNG commented 1 year ago

Greetings and Regards I was really great. Is it possible to guide me so that I can add the Persian Hijri calendar?

mymth commented 1 year ago

I'm not an expert of calendar system, so what I'm going to say may be wrong. (Please correct me if you find something incorrect.)

To use a calendar not supported by JavaScript's Date objects, you need custom Date objects that can handle that calendar because the rules to determine the first/last of month/year are different. Without them, you'll have a problem with getting previous/next month of a date.

Unfortunately, this library is designed to work with JavaScript's native Date objects only. So, I think you'll probably need to find or create a date library that supports the Persian calendar, fork this project, and rewrite all the parts that use Date object to use that library's Date object.

wpV2rayNG commented 1 year ago

I'm not an expert of calendar system, so what I'm going to say may be wrong. (Please correct me if you find something incorrect.)

To use a calendar not supported by JavaScript's Date objects, you need custom Date objects that can handle that calendar because the rules to determine the first/last of month/year are different. Without them, you'll have a problem with getting previous/next month of a date.

Unfortunately, this library is designed to work with JavaScript's native Date objects only. So, I think you'll probably need to find or create a date library that supports the Persian calendar, fork this project, and rewrite all the parts that use Date object to use that library's Date object.

Thank you for your good answer, yes, ready-made libraries such as Moment.js FA have been written, but unfortunately, I am not very professional in the field of JS to be able to add it to the calendar.

mymth commented 1 year ago

So am I when it comes to Persian (or anything non-western or non-east-Asian) things.

Anyway, anything that cannot be done with JavaScript language itself is outside the scope of this project. (I'm sorry, but this is my personal hobby project. To support such things is too much for me.)

Hope some Persian-speaking JS programmer will find this and help you.

wpV2rayNG commented 1 year ago

So am I when it comes to Persian (or anything non-western or non-east-Asian) things.

Anyway, anything that cannot be done with JavaScript language itself is outside the scope of this project. (I'm sorry, but this is my personal hobby project. To support such things is too much for me.)

Hope some Persian-speaking JS programmer will find this and help you.

Maybe one day I will write it myself, thanks again