Skip to content

Commit c0ea087

Browse files
committed
fix: persian calendar converter is now using astronomical calculations and fixes leap year calculations. added more tests and cleaned the underlayer converter library.
1 parent fc9ef7a commit c0ea087

File tree

6 files changed

+709
-643
lines changed

6 files changed

+709
-643
lines changed

Diff for: src/calendarSystems/PersianCalendarSystem.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default class PersianCalendarSystem extends CalendarSystemBase {
5353
date.getMonth() + 1,
5454
date.getDate()
5555
);
56-
const persianDateArray = CalendarUtils.jd_to_persian(julianDay);
56+
const persianDateArray = CalendarUtils.jd_to_persiana(julianDay);
5757
return {
5858
year: persianDateArray[0],
5959
month: persianDateArray[1] - 1, // -1 because the Persian month is 0-based
@@ -63,8 +63,8 @@ export default class PersianCalendarSystem extends CalendarSystemBase {
6363

6464
// Expects a zero-based month index
6565
convertToGregorian(persianYear, persianMonth, persianDay) {
66-
const julianDay = CalendarUtils.persian_to_jd(persianYear, persianMonth + 1, persianDay);
67-
const gregorianDateArray = CalendarUtils.jd_to_gregorian(julianDay);
66+
const julianDay = CalendarUtils.persiana_to_jd(persianYear, persianMonth + 1, persianDay);
67+
const gregorianDateArray = CalendarUtils.jd_to_gregorian(julianDay + 0.5);
6868
return {
6969
year: gregorianDateArray[0],
7070
month: gregorianDateArray[1] - 1, // -1 because the Gregorian month is 0-based

0 commit comments

Comments
 (0)