Marmo / debitum

free and libre IOU tracker for Android
GNU General Public License v3.0
85 stars 7 forks source link

Please add support for Bikram Sambat Calendar (Nepal) #116

Open pragyanone opened 2 years ago

pragyanone commented 2 years ago

In my country, Nepal, Bikram Sambat calendar is used instead of the ubiquitous Gregorian system.

Being a small and underdeveloped country, not many international apps support the national calendar system, and the citizens have a hard time to just convert the date between these two systems.

Debitum, in my view, is a great app of its kind.

I, myself have written a python script to convert dates between these two systems. I would like the dev. to add support for BS calendar system.

(will post a brief explanation of my script in the comment below.)

pragyanone commented 2 years ago

adbs.py Summary: You just need to call the functions ad2bs & bs2ad for the conversions.

Explanation: Unlike the AD calendar, the BS calendar doesn't have fixed number of days in a month. (Yes, in AD calendar, February has 29 days every leap year but in BS calendar, there doesn't seem to be a straight algorithm.) This has to do with the fact that BS is a lunar calendar, whereas AD is a solar one.

So, for BS calendar, we basically have a database of days in months for several future years ahead. (bs_data python string).

Algorithm:

  1. database
  2. fix a datum day, of which, date in both system is known (1918/4/13 AD = 1975/1/1 BS)
  3. then count the days between a given date and the datum, and do simple addition/subtraction to achieve date in another system. Example: 3.1 say, you need to convert from 1918/4/14 AD to BS 3.2 count the days between 1918/4/14 AD and the AD datum, 1918/4/13 AD = 1 3.3 add the number of days in the BS datum, 1975/1/1 + 1 = 1975/1/2

Notes:

Marmo commented 2 years ago

Hi @pragyanone , I would really like to support other calendar systems. What I would not like to do is to re-program many components that are normally provided by Android, like the date picker.

Doing a quick search I could not find info about if Android supports non-Gregorian calendars or not.

pragyanone commented 1 year ago

Hi @Marmo, I've a workaround that will support all calendars worldwide. You could provide an option to remove date validations! Then in the default transaction entry, just increment days in every month; if it's a new month, user will change the date to next month-day1. Then, again keep incrementing the date.

I know this feels unethical, but it will support any calendar.