almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

Support of different calendar types #2026

Open ZvikaZ opened 8 years ago

ZvikaZ commented 8 years ago

Hi.

Is it possible to have some API that the user can implement an arbitrary function that will return a date string to be shown? This is useful to support non Gregorian calendars (such as Hebrew, Arabic or Chinese) or even non standard calendars (e.g. https://en.wikipedia.org/wiki/Seleucid_era )

Thanks

brichbe commented 8 years ago

Did you read the docs about the format config option? This allows you to customize the time axis labels, per the spec of moment.js.

ZvikaZ commented 8 years ago

Yeah, I've read the docs. It gives a lot of formatting possibilities for the Gregorian calendar. Today's is 20th day of the 8th month of the 2016 year, and this info can be formatted in a lot of ways (20-08-16, 20/08/16, 20/8/2016, 8.20.16, August 20th 2016, 20 אוגוסט, and a lot of other combinations in various languages)

But the human cultures created other calendars as well. Today is also 16th day of 11th month of the 5776th year of the Jewish calendar. Again - this different day/month/year combination (that represents the very same day...) can be formatted in various ways, in various languages (16 Av 5776, ט"ז אב תשע"ו, etc.)

There are also ancient calendars that might be supported (egyptian, greek, etc). In my specific case, I need to use some ancient Jewish calendar that was influenced by the greeks - the Seleucid_era.

A user might even want to use some private calendar - like counting from the birth of some grandfather, or some family's important historical event...

I don't think that all these possibilities can be hard-coded into any library.

My suggestion is to have an option, that the timeline mechanism will call a function, that will be supplied by the user, and it will be the user's responsibility to implement whatever crazy calendar they wish to support. The function will get the 'regular' date as parameter, maybe some information regarding the expected result (only year, or year+month, etc.), and it will return a formatted string.

Thanks

khoramshahy commented 6 years ago

I need this feature for jalali(solar) calendar too

s7726 commented 6 years ago

I believe this would allow for what I'm trying to do as well. https://stackoverflow.com/questions/51217396/vis-js-display-all-dates-as-fiscal-year