זה הקוד המלא ב JS
const Hebcal = require('hebcal'); const moment = require('moment'); let gematriya = require('gematriya'); let arr = [ '20220828', // א אלול תשפב יום ראשון '20250825', // א אלול תשפה יום שני '20240904', //א אלול תשפד יום רביעי '20260814', // א אלול תשפו יום שישי ]; let days = ['א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז']; for (let i in arr) { const data = arr[i]; let momentDate = moment(data); let HDate = new Hebcal.HDate(momentDate.toDate()); console.log('-------------------'); for(let i = 0; i < 40; i++) { console.log(getElulTehilimDay(momentDate, HDate), days[momentDate.day()], HDate.getMonth(), gematriya(HDate.getDate())); momentDate.add(1, 'days'); HDate = new Hebcal.HDate(momentDate.toDate()); } } function getElulTehilimDay(momentDate, HDate) { let weekDay = momentDate.day(); if (HDate.getMonth() === 6 || (HDate.getMonth() === 7 && HDate.getDate() <= 9)) { // הפונקציה אמורה להחזיר את מספר היום. הימים נספרים מתחילת חודש אלול 6 ועד יום כיפור שזה תאריך 10 בחודש 7. // ימי שישי ושבת אינם נספרים וכן ימי ראש השנה 1 ו 2 בתשרי, למעט יום 29 באלול שנספר גם אם הוא חל ביום שישי וכן ערב יום כיפור if ((weekDay === 5 && HDate.getDate() !== 29 && (!(HDate.getMonth() === 7 && HDate.getDate() === 9))) || weekDay === 6 || (HDate.getMonth() === 7 && (HDate.getDate() === 1 || HDate.getDate() === 2))) { return -1; } if (HDate.getMonth() === 6) { // חודש אלול //תחילת החודש אין שארית if (HDate.getDate() <= 7) { //כל עוד לא עברה שבת אין צורך למעט את שישי ושבת //ה weekDay מתחיל מ 0 ולכן יש להוסיף 1 if (weekDay + 1 >= HDate.getDate()) { return HDate.getDate(); } else { // אם התאריך גדול משבת יש להוריד 2 return HDate.getDate() - 2; // ר"ח אלול לא יכול לצאת בשבת ולכן תמיד יש להוריד 2 } } //הפרש הימים של השארית מחלוקה לשבועות, ההפרש נמדד ג"כ האם כבר עברה שבת בתוך ימי ההפרש או עוד לא let number = HDate.getDate() % 7; if (number > weekDay && number - weekDay > 2) { number -= 2; } // הרעיון הוא חלוקה לשבועות והכפלה עד 5 כי בכל שבוע יורדים 2 ימים ואז מוסיפים את השארית הנכונה return parseInt(HDate.getDate() / 7) * 5 + number; } else { //ערב יום כיפור if (HDate.getDate() === 9) { return 28; } else if (HDate.getDate() === 8 && weekDay === 4) { // בשנה שא' אלול ביום רביעי מפצלים את סדר 25 לשניים ואז אין 25 אלא רק 26 ו 27 return 27; } else if (HDate.getDate() === 7 && weekDay === 3) { return 26; } let RoshHashana = 2; // כשחל א אלול ביום רביעי ואז ראש השנה ביום חמישי if ((HDate.getDate() === 4 && weekDay === 0 ) || (HDate.getDate() === 5 && weekDay === 1) || (HDate.getDate() === 6 && weekDay === 2) || (HDate.getDate() === 7 && weekDay === 3) || (HDate.getDate() === 8 && weekDay === 4)) { RoshHashana = 1; } // כשחל א אלול ביום שישי, ראש השנה חל ביום ראשון if ((HDate.getDate() === 3 && weekDay === 1 ) || (HDate.getDate() === 4 && weekDay === 2) || (HDate.getDate() === 5 && weekDay === 3) || (HDate.getDate() === 6 && weekDay === 4)) { RoshHashana = 0; } // למעשה בחודש אלול יש תמיד 21 סדרים לא משנה באיזה קביעות שנים, וממילא תשרי מתחיל תמיד ב 22 if (HDate.getDate() <= 7) { if (weekDay >= HDate.getDate()) { return 21 + HDate.getDate() - RoshHashana; } else { return 21 + HDate.getDate() - 2 - RoshHashana; } } return (21 + parseInt(HDate.getDate() / 7) * 5 + (HDate.getDate() % 7)) - RoshHashana; } } // return -1; }
ח
חוקר
@חוקר