dhlab-basel / JDNConvertibleCalendar

Different calendars can be freely converted using Julian Day Number
GNU Affero General Public License v3.0
4 stars 3 forks source link

Jewish calendar new #18

Open gautschr opened 4 years ago

gautschr commented 4 years ago

Number of possible months in a year has to be adjusted in order to correct Jewish month lengths correctly.

tobiasschweizer commented 4 years ago
export class JewishCalendarDate extends JDNConvertibleCalendar {

        public readonly calendarName = JDNConvertibleCalendar.jewish;

        // Determine the number of months of a certain Jewish year
        public readonly monthsInYear = 13;

monthsInYear has to be a method that takes the year as an argument. In case of the Jewish calendar, it has to call JDNConvertibleConversionModule.JewishCharact(jewishYear). For the other calendars, 12 will be returned.

tobiasschweizer commented 4 years ago

handleMonthTransposition has to determine the number of months in each year

// get remaining months to shift: max. this.monthsInYear - 1
            const monthsToShift = Math.abs(months) % this.monthsInYear;

The following cases have to be handled correctly:

  1. current month + months is > 6 or < 8:
    • if current year has 12 months, there is no month 7. If the current month is 6 and months is 1, then it has to shift to month 8. If the current month is 8 and months is -1, then it has to shift to month 6.
  2. modulo for several years:
    • get year of given calendarDate (current year)
    • get number of months (nmo) for current year using JDNConvertibleConversionModule.JewishCharact(jewishYear)
    • if months <= nmo -> do shift considering 1.
    • if months > nmo -> get number of months (nmo) for following/previous year, repeat above until months exceeded
emargareten commented 4 years ago

@tobiasschweizer any updates for this PR?

tobiasschweizer commented 4 years ago

@tobiasschweizer any updates for this PR?

No, unfortunately not. Sadly, I don't have any time to work on this PR. Could you help in some way? Even just figuring out the algorithm for the months would be a big help.

tobiasschweizer commented 3 years ago

@emargareten Would you have any resources to help figure out the algorithm for dealing with the months?