Qalculate / libqalculate

Qalculate! library and CLI
https://qalculate.github.io/
GNU General Public License v2.0
1.79k stars 144 forks source link

Calendar conversion #91

Open majumeke opened 6 years ago

majumeke commented 6 years ago

since there are numerous calendars in the world:

https://en.wikipedia.org/wiki/List_of_calendars

would you consider adding a conversion function to Qalculate! so that we can be able to convert between these various calendars ? it would be nice if it could be implemented by entering the year to be converted into the expression entry box(2018 gregorian to coptic) or through a dialog box where a user can enter a year in one calendar and have it displayed in the various other calendars, an example:

user enters 2968 which Qalculate! will recognize as the current Berber year and return:

2018 <== Gregorian calendar 2562 <== Buddhist calendar 1734 <== Coptic calendar 5778 <== Hebrew calendar 1396 <== Iranian calendar 4351 <== Korean calendar etc(ideally all current calendars would be returned)

a bonus feature would be the ability to convert dates. an example would be to convert the Islamic date today: 7th, Ramadan(9th month), 1439 into the Hebrew calendar which would be 8th, Sivan(9th month), 5778.

Thank you.

hanna-kn commented 6 years ago

That is a good idea.

Unless only the current year is supported, full date support is necessary and automatic calendar recognition is not practical.

I think that support for multiple calendars should be added to the date() function, for conversion to Gregorian calendar, as a conversion option for (Gregorian) dates in the result, and as a conversion dialog in the GUI.

It should not be difficult to achieve for most common calendars, but I will need to do some research since I'm not at all familiar with non-Gregorian calendars. It would be helpful if you could point me in the direction of good conversion formulas.

majumeke commented 6 years ago

excellent, i appreciate your willingness to add this to Qalculate!

onto the formulas:

i've found this page with date conversion done in javascript with a downloadable package for offline use:

https://www.fourmilab.ch/documents/calendar/

a user has posted an updated package with refinements here on GitHub here:

https://github.com/catull/CalendarConverter

secondly i stumbled upon the book Calendrical Calculations by Nachum Dershowitz and Edward M. Reingold:

https://www.amazon.com/Calendrical-Calculations-Ultimate-Edward-Reingold/dp/1107683165/ref=dp_ob_title_bk

the book ships with an application known as Calendrica that is used for date conversions and the authors have kindly supplied its source code on the books website:

http://www.cambridge.org/ch/academic/subjects/computer-science/computing-general-interest/calendrical-calculations-ultimate-edition-4th-edition?format=PB

it is written in LISP but a user has created a python library for version 3 of Calendrica here on GitHub:

https://github.com/espinielli/pycalcal

and another user has ported it to Erlang:

https://github.com/ferd/calcalc

the app itself can be accessed as a Java applet on this page:

http://www.cs.tau.ac.il/~nachum/calendar-book/Calendrica.html

also there's an excellent freeware program called Calendar Magic its Calendar Comparison/Conversion feature has been implemented really well. perhaps you could model Qalculate's GUI after it

cm

hanna-kn commented 6 years ago

I've finished calendar conversion for an initial set of calendars.

screenshot

majumeke commented 6 years ago

wow, this looks really good Thank you. can't wait to see more calendars added.

majumeke commented 6 years ago

looking good in 2.6. i especially like how you've handled the complex Chinese calendar and how the different calendars have their native month names. please keep it up and i hope to see more calendars added like the Bengali calendar, Buddhist calendar, etc. but for now this can be considered closed.

Thank you.

h-h-h-h commented 2 years ago

this can be considered closed.

Issue can be closed by issue creator or repo owner.