Skip to content

Commit

Permalink
fix: persian calendar converter is now using astronomical calculation…
Browse files Browse the repository at this point in the history
…s and fixes leap year calculations. added more tests and cleaned the underlayer converter library.
  • Loading branch information
amirhmoradi committed May 22, 2023
1 parent fc9ef7a commit c0ea087
Show file tree
Hide file tree
Showing 6 changed files with 709 additions and 643 deletions.
6 changes: 3 additions & 3 deletions src/calendarSystems/PersianCalendarSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class PersianCalendarSystem extends CalendarSystemBase {
date.getMonth() + 1,
date.getDate()
);
const persianDateArray = CalendarUtils.jd_to_persian(julianDay);
const persianDateArray = CalendarUtils.jd_to_persiana(julianDay);
return {
year: persianDateArray[0],
month: persianDateArray[1] - 1, // -1 because the Persian month is 0-based
Expand All @@ -63,8 +63,8 @@ export default class PersianCalendarSystem extends CalendarSystemBase {

// Expects a zero-based month index
convertToGregorian(persianYear, persianMonth, persianDay) {
const julianDay = CalendarUtils.persian_to_jd(persianYear, persianMonth + 1, persianDay);
const gregorianDateArray = CalendarUtils.jd_to_gregorian(julianDay);
const julianDay = CalendarUtils.persiana_to_jd(persianYear, persianMonth + 1, persianDay);
const gregorianDateArray = CalendarUtils.jd_to_gregorian(julianDay + 0.5);
return {
year: gregorianDateArray[0],
month: gregorianDateArray[1] - 1, // -1 because the Gregorian month is 0-based
Expand Down
Loading

0 comments on commit c0ea087

Please sign in to comment.