How to change datepicker for non-Gregorian calendars?

Hey there.

I need to change datepicker to a modified version of jqueryu ui datepicker. How should I do that?

You shouldn’t, since we’re actually replacing the old jquery ui datepicker with a new react-based one in 2.3, so any changes you make there would be wasted soon once we release 2.3.

What is your actual goal, i.e. what changes do you want to make?

Thanks,

My goal is to use a datepicker that supports https://en.wikipedia.org/wiki/Solar_Hijri_calendar.

It looks like our new datepicker does not support this either, since there’s an open issue for it in their repo:

I don’t think there is any straightforward way to support non-gregorian calendars in Indico, either out of the box or by manually changing the code… Keep in mind that this isn’t only a display thing but likely also requires conversions between calendar formats (since Indico will always use and store gregorian dates internally). So this would likely be a significant change (and thus pain during every Indico upgrade)…

Are there any major applications out there that support other calendar types?

Storing dates as Gregorian is ok, the only problem is the view.
http://babakhani.github.io/PersianWebToolkit/doc/datepicker/example/

This datepicker has the feature to store gregorian but show Hijri. I think it does the conversion itself.

You mentioned the react datepicker, there’s a react version here, but I don’t think it’s exactly the same:

1 Like

I think it is only a display thing. Actually Indico stores the dates in Unix time and does not know about Gregorian or other calendars itself. :wink:

The conversion seems to be as simple as the story of Celsius and Fahrenheit: https://www.arabic-for-nerds.com/convert-hijri-date/ (I am not sure about that; can you confirm @Ali_Padida?)
Actually I hoped that it was already implemented in standard libraries when playing with the date translations yesterday. But now I learned at least what the Ů… stands for! Thank you! :slightly_smiling_face:

At least we don’t use UNIX timestamps anywhere. Dunno what postgres uses internally when storing date/time values.

Yes sir, it’s only a display thing, so I’ll only need to replace css and js files, but I don’t know which ones and where.

Just like Hijri date that you mentioned, it’s done by calculations:

You’re welcome :sweat_smile:

My money is on Unix time (in 31 bits until 2038).

@Ali_Padida, I think there was some confusion: You asked for support the Persian “Shemsi (== solar) Hijri” (aka Jalali and official in Iran and Afghanistan), which is not identical to muslim lunar Hijri calendar (official in many arabic muslim countries) referenced by @ThiefMaster. Right?
What is not clear to me is, if you wanted to use a datepicker (which needs a rather complex implementation with RTL awareness and graphical representation), or if you would be satisfied with “just” a translation, which might be achievable with jdatetime, even in Western and Persian writing (selected via locale).

But besides the cultural aspect, which is very enlightening and enriching (at least for me), is it more than a home or sandbox project that you work on? (@ThiefMaster had asked which application you consider, but you have not answered that question.)
Isn’t it pointless to implement an Iranian calendar before even having an embryo of a translation of Indico for Farsi? Calendars are beyond the aspects of translation itself. Yesterday I stated ironically that some feature would probably be good for Indico 4.0. In that sense, I am afraid non-Gregorian calendars will be for Indico 5.0 earliest. But I may be wrong; if there are little things that make many people happy, they may come before. Let us know.

You asked for support the Persian “Shemsi (== solar) Hijri” (aka Jalali and official in Iran and Afghanistan), which is not identical to muslim lunar Hijri calendar (official in many arabic muslim countries) referenced by @ThiefMaster. Right?

What I meant by identical was that it’s possible to convert Gregorian to “Shemsi Hijri” with some math calculations.And its classes have already been written and ready to use in many languages including javascript that many persian-datetime picker libraries use.

What is not clear to me is, if you wanted to use a datepicker (which needs a rather complex implementation with RTL awareness and graphical representation), or if you would be satisfied with “just” a translation, which might be achievable with jdatetime, even in Western and Persian writing (selected via locale).

Sorry I made it confusing, I do need to use a datepicker with RTL awareness and graphical representation. I haven’t studied indico code that much to know if it’s possible and how hard it could be to replace the default jquery ui datetime picker with another one.

But besides the cultural aspect, which is very enlightening and enriching (at least for me), is it more than a home or sandbox project that you work on?

I don’t have any specific plans, but my goal for now is to translate the whole indico to Persian. I was able to learn how to translate “.po” strings and compile them to “.mo”. The next challenge I have is the date-time picker.

(@ThiefMaster had asked which application you consider, but you have not answered that question.)

Sorry I took the application as library and named a Persian datetime picker. I don’t recall any applications offering Persian calendar support out of Iran because there are almost no ways for Iranian to use services outside the country and all the services inside Iran use Persian calendars only.

Well then if it’s not going to be added soon, I’ll try to look for css and html files that are related to the calendar to see if I could make any non-breaking changes or not.

Very good. Would you mind to share your work on Transifex?
How did you solve the RTL aspects?

Sure, I will share gradually. Actually I haven’t come up with RTL challenges yet but I assume I’ll have to modify css files.

… which will happen as a function of the dynamicall selected language?

Honestly I haven’t thought about it yet. I’ll try to do so, and if I be able to add such flexibility, I’ll send a pull request on GitHub.

1 Like

Looks like the react-based datepicker supports persian format: http://airbnb.io/react-dates/?path=/story/singledatepicker-sdp--non-english-locale-persian

The way it’s implemented looks super simple as well so if there is ever a persian translation for Indico we could probably enable this in the date pickers for anyone selecting the persian language!

This is the beauty of Open Source. If it isn’t there, you can add it. And everyone is free to use it, no barriers and no politics.

It’s a lunar calendar, so there are for sure corrections every few years. And from what I understood, conversion tables are employed, so things will always be somewhat approximated.
So, yeah, it’s not as simple as F ⇄ C and you’d actually have to make sure you don’t convert things back and forth many times, which might result in accumulated error.

UPDATE: Sorry, just realized Iran uses the solar version, so, never mind. You’re right.

Interesting, indeed!

Yes, but there we go already for the discussion: I am not sure, if the calendar choice should be tightly and exclusively coupled to the language. All countries in the world (I think) use the Gregorian calendar due to commercial and political connections, at least in inter-national communication. But sometimes it is convenient to look up dates in local variants for countries where those still determine holidays and vacation for example.
The same can be true from the outside (check the SH calendar for conflichts even if you only speak english).

:smile:
(And Afghanistan!)
Yes, I think we all were trapped and learned something from this thread.
And probably those “modified solar” calendars, like the Chinese one, are most likely to be useful in Indico first.
Actually, I understood that SH is the most accurate calendar, as it is based on astronomical observations (spring point). Meanwhile, we keep calling our 10th month october. :wink:


I just found this curiosity on wp. It contains (left to right, top to bottom) the “Roman” calendar (Julian with years since Hijra), Hijri lunar, Julian and Gregorian. All four were used in the Ottoman Empire in 1896 (AD).
Times have become simpler since then. But the last country in Europe only adopted the Gregorian Calendar in 1926, still less than 100 years ago. Fortunately the oldest event in Indico dates only from 1954.