-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar.js
33 lines (26 loc) · 1.08 KB
/
calendar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
document.addEventListener('DOMContentLoaded', function () {
const { HebrewCalendar, HDate } = window.Hebcal;
// Get today's Gregorian date
const today = new Date();
// Convert it to a Hebrew date
const hebrewDate = new HDate(today);
// Get the current Hebrew month and year
const monthName = hebrewDate.getMonthName();
const year = hebrewDate.getFullYear();
// Start building the calendar HTML
let calendarHTML = `<div class="month">${monthName} ${year}</div>`;
calendarHTML += '<div class="days">';
// Get the number of days in the Hebrew month
const daysInMonth = hebrewDate.daysInMonth();
for (let day = 1; day <= daysInMonth; day++) {
const dayHebrewDate = new HDate(day, hebrewDate.getMonth(), hebrewDate.getFullYear());
calendarHTML += `
<div class="day">
<div>${day}</div>
<div class="hebrew-date">${dayHebrewDate.renderGematriya()}</div>
</div>
`;
}
calendarHTML += '</div>';
document.getElementById('calendar').innerHTML = calendarHTML;
});