debitum icon indicating copy to clipboard operation
debitum copied to clipboard

Please add support for Bikram Sambat Calendar (Nepal)

Open pragyanone opened this issue 2 years ago • 3 comments

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 avatar Jul 03 '22 15:07 pragyanone

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:

  • The dates are first converted to "days since datum" in step 3.2 for the arithmetic (python functions: ad2days & bs2days).
  • The resulting days from step 3.3 are converted back to dates using days2ad & days2bs.

pragyanone avatar Jul 03 '22 15:07 pragyanone

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.

Marmo avatar Jul 05 '22 14:07 Marmo

I agree. I don't think BS calendar is supported by default. I can not ask you to code the date picker either.

I wonder if you could leave the date picker in the default AD calendar, AND, add an "Extras" section in settings, and just use my python functions from above to convert the AD dates provided by Android.

For the date picker,

  • one could quickly calculate in their head, the approximate BS to AD date/month
  • pick AD date in the date picker
  • but, get the results displayed in BS calendar, IF ENABLED IN SETTINGS

(I guess you will be reluctant to apply this workaround because it won't be neat, but ... 🙂🙂)

pragyanone avatar Jul 05 '22 14:07 pragyanone

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.

pragyanone avatar Aug 20 '22 03:08 pragyanone