Skip to content

Commit

Permalink
fix hijri date
Browse files Browse the repository at this point in the history
  • Loading branch information
IamRezaMousavi committed Jul 9, 2024
1 parent 5422734 commit e777c4d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions [email protected]/hijriDate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */
/* eslint no-use-before-define: "off", no-param-reassign: "off" */

/*
* https://github.com/SCR-IR/tarikh-npm
*/
Expand Down Expand Up @@ -66,7 +67,6 @@ function _julianDayToGregorian(julianDay) {
for (gM = 0; gM < 13 && gD > gDoM[gM]; gM++)
gD -= gDoM[gM];


return [gY, gM, gD];
}

Expand All @@ -85,7 +85,6 @@ function _julianDayToHijriA(julianDay) {
if (im > 12)
im = 12;


id = 1 + tmp - ~~((29.5 * (im - 1)) + 0.5);
return [iy, im, id];
}
Expand All @@ -104,7 +103,6 @@ function _hijriToJulianDay(iY, iM, iD) {
for (let m = 1; m < iM; m++)
julianDay += HILAL.iDoM[iY][m];


break;
}
}
Expand All @@ -127,7 +125,6 @@ function _julianDayToHijri(julianDay) {
for (iM = 1; iM < 13 && iD > HILAL.iDoM[iY][iM]; iM++)
iD -= HILAL.iDoM[iY][iM];


break;
}
}
Expand All @@ -137,12 +134,13 @@ function _julianDayToHijri(julianDay) {

function _hilalIM(country = 'IR') {
return {
// https://github.com/ilius/starcal/blob/master/scal3/cal_types/hijri-monthes.json
IR: {
startYear: 1427, /* =iDoM:firstYear */
startJD: 2453767, /* =_hijriAToJulianDay(startYear,1,1) */

endYear: 1445, /* =iDoM:lastYear */
endJD: 2460499, /* =_hijriAToJulianDay(endYear+1,1,1)-1 */
endYear: 1446, /* =iDoM:lastYear */
endJD: 2460735, /* =_hijriAToJulianDay(endYear,endMonth+1,1)-1 */

iDoM: {
1427: [355, 30, 29, 29, 30, 29, 30, 30, 30, 30, 29, 29, 30],
Expand All @@ -163,7 +161,8 @@ function _hilalIM(country = 'IR') {
1442: [354, 29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29],
1443: [354, 29, 30, 30, 29, 29, 30, 29, 30, 30, 29, 30, 29],
1444: [354, 30, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 29],
1445: [355/* |354*/, 30, 30, 30, 29, 30, 29, 29, 30, 30, 29, 30, 29/* |30 :Delta*/],
1445: [354, 30, 30, 30, 29, 30, 29, 29, 30, 29, 30, 29, 29],
1446: [238, 30, 30, 30, 29, 30, 30, 29, 30],
/*
Delta = endJD - _hijriAToJulianDay(endYear,12,29)
*/
Expand Down

0 comments on commit e777c4d

Please sign in to comment.