Casvt / MIND

A simple self hosted reminder application that can send push notifications to your device. Set the reminder and forget about it!
https://casvt.github.io/MIND/
GNU General Public License v3.0
201 stars 10 forks source link

Support lunar calendar #79

Closed hausen1012 closed 5 months ago

hausen1012 commented 5 months ago

Thank you for providing such a useful open source project. I would like to mention my requirement, but I am not sure if it is feasible

Is your feature request related to a problem? Please describe.

In China, most people celebrate their birthdays according to the lunar calendar. When I set a family member's birthday, I need to convert it to the solar calendar. Then, the corresponding solar calendar dates for each year's lunar calendar are different.

So, I hope that when choosing a date, you can choose either a lunar date or a solar date.

Describe the solution you'd like

When adding a lunar date, it is automatically converted to a solar date. After the task runs, the next conversion is automatically performed.

Casvt commented 5 months ago

I don't know a lot about the lunar calendar (I'm west-European) so could you confirm something for me?

  1. If I have a lunar date, I can not simply add a year and it will be the same day a year later. The same days one year apart will have different dates.
  2. I can not convert the lunar date to it's solar date, add a year, then convert it back to a lunar date.
  3. Based on bullet 1 and 2, we can say that the calculations needed to properly find the date of the same day but a year later, are totally different from how you do them for the solar calendar.

Because if so, we're out of luck. There is a python library for converting between solar and lunar. However, there is no python library for adding intervals (= finding the date of the birthday next year) like we use for the solar calendar in MIND.

hausen1012 commented 5 months ago

Thank you for your reply. I am happy to discuss this issue with you.

  1. Regarding the lunar calendar, generally speaking, it is possible to simply add one year without changing the date. However, there may be leap months in the lunar calendar, which means there may be two identical months in a year.

  2. It seems that the conversion between the lunar and solar calendars can be calculated, and I learned about it through this link, Python公历转换农历及简易万年历 . Surprisingly, I found that this calculation seemed to be very accurate, and even after checking the correspondence for 2070, it was correct.

I can indeed solve the problem of transitioning between the lunar and solar calendars in this way, but the troublesome point is that there may be leap months, but I don't think this is a critical issue because the most important one is the first month. And even if there is a leap month, there won't be two birthdays in a year.

Finally, I would like to say that I'm sorry, my English is not good. These contents were translated through translation software. If you have any questions, please feel free to communicate with me at any time.

Casvt commented 5 months ago

Thanks for the clarifications. MIND tries to be as accurate and consistent as possible with it's timings and interval calculations. It either has to be correct always or not do it at all. So in order to implement a lunar calendar, it would need to be implemented in such way that it will always work correctly, no matter which year it is, if it is a leap year or not, if it is a certain holiday (if I understand the calendar correctly), etc.

I'm not even close to properly understanding the lunar calendar. If I'm going to implement it, I want to let an external library do all the complicated calculations and let it handle all the special cases (like leap years and having two identical months in a year). It does not seem like there is such a library currently (which I find very surprising by the way) so I think it ends here.

The link you shared supplies code for converting between lunar and solar. This doesn't seem like it will suffice, seeing that it won't really help with properly calculating dates at an interval (for the solar calendar, MIND uses a separate library for calculating intervals exactly for this reason). What I mean with that is that knowing what a certain lunar date is as a solar date won't really help with determining what the lunar date is next year.

I don't have the knowledge myself to implement repeating reminders for a lunar calendar, so unless a library comes out that does it for me, I cannot help you.


P.S. I don't know what translation software you're using, but the English that comes out is excellent.

hausen1012 commented 5 months ago

You are right, there are also holidays in the lunar calendar. Perhaps the leap month I mentioned to you may have misled you, but in fact, it can be ignored because it is not important, just an objective existence.

In fact, to calculate the next cycle in the lunar calendar, only the year needs to be modified, without the need to modify other parts.

Regarding the part of the lunar calendar, the most important interval is actually the year. Here, the use of the lunar calendar mainly involves recording birthdays and our traditional festivals.

My idea is to perhaps add a module that distinguishes it from timed reminders, recurring reminders, and weekday reminders. This module can only select lunar dates and only has timed reminders and annual recurring reminders, as I mentioned earlier, other time intervals are not important.

Perhaps this may be a bit difficult for you to understand, but in fact, if you only need to remind by year, you only need to make the year+1 and then calculate a Gregorian date. So, using the method in the link I provided above is actually very simple.

If this plan can be implemented, I think it's really cool. But no matter what, the current version is already very user-friendly, thank you very much!