Convert Gregorian dates to their Hebrew calendar equivalents accurately and instantly.
Gregorian to Jewish Date Converter
Select the date you want to convert.
Conversion Results
Jewish Date
Hebrew Year:
Hebrew Month:
Hebrew Day:
Parashah:
This calculator uses a complex algorithm based on astronomical calculations and historical rabbinic conventions to determine the Jewish date. It accounts for leap years in both the Gregorian and Hebrew calendars and the precise start of each Hebrew month.
Results copied!
Hebrew Calendar Year Overview
Chart showing the number of days in each month for a typical Hebrew year.
Hebrew Month Names and Durations
Hebrew Month
English Name (Approx.)
Days (Standard Year)
Days (Leap Year)
Nisan (ניסן)
March-April
30
30
Iyar (אייר)
April-May
29
29
Sivan (סיון)
May-June
30
30
Tammuz (תמוז)
June-July
29
29
Av (אב)
July-August
30
30
Elul (אלול)
August-September
29
29
Tishrei (תשרי)
September-October
30
30
Cheshvan (חשון)
October-November
29 or 30*
29 or 30*
Kislev (כסלו)
November-December
29 or 30*
29 or 30*
Tevet (טבת)
December-January
29
29
Shevat (שבט)
January-February
30
30
Adar I (אדר א')
February-March (Leap Year Only)
–
30
Adar II (אדר ב')
March (Leap Year) / February (Standard Year)
29
29
*The lengths of Cheshvan and Kislev vary to ensure Rosh Hashanah falls on the correct day of the week.
What is the Jewish Date Calculator?
The Jewish Date Calculator is a specialized tool designed to convert dates from the widely used Gregorian calendar (the civil calendar) into the corresponding date on the Hebrew calendar, also known as the Jewish calendar. This calendar is lunisolar, meaning it is based on both the cycles of the moon (for months) and the sun (for years). It is used primarily for determining the dates of Jewish holidays, Torah readings, Yahrzeits (anniversaries of a death), and other religious observances.
Who should use it?
Individuals preparing for Jewish holidays and festivals.
People wanting to know the Hebrew date for a specific event or birthday.
Anyone observing a Yahrzeit or Brit Milah (circumcision ceremony).
Students of Jewish history, tradition, or religious studies.
Individuals seeking to understand the timing of biblical events.
Common Misconceptions:
It's purely lunar: While the months are lunar, the Hebrew calendar adds an extra month (Adar I) in leap years to keep it synchronized with the solar year and seasons.
It's static: The lengths of two months (Cheshvan and Kislev) can vary to ensure that major holidays like Rosh Hashanah and Yom Kippur do not fall on inconvenient days of the week.
It started recently: The Hebrew calendar has a history dating back thousands of years, with its current form largely established by Hillel II in the 4th century CE.
Jewish Date Calculator Formula and Mathematical Explanation
The conversion from the Gregorian to the Hebrew calendar is a complex process that involves several astronomical and calendrical rules. It's not a simple linear conversion but rather a sophisticated algorithm. The core idea is to calculate the number of days elapsed since a fixed epoch (a reference point in time) in both calendars and then use this to determine the corresponding date in the Hebrew system.
Key Concepts:
Epoch: The Hebrew calendar epoch is traditionally set at the creation of the world, calculated to be October 7, 3761 BCE (in the Julian proleptic calendar).
Lunar Months: Hebrew months begin with the new moon. The average length of a lunar month is approximately 29.53 days.
Solar Year: The Hebrew calendar aims to align with the solar year to keep festivals in their correct seasons.
Leap Years: To reconcile the lunar and solar cycles, a 13th month (Adar I) is added 7 times within a 19-year cycle (Metonic cycle).
Postponements (Dechiyot): Rules exist to prevent certain holidays from falling on specific days of the week to avoid religious complications (e.g., Yom Kippur not on Friday or Sunday).
Simplified Calculation Steps:
Calculate Days Since Epoch: Determine the total number of days that have passed from the Hebrew epoch (October 7, 3761 BCE) to the given Gregorian date. This involves complex calculations considering Gregorian leap years.
Determine Hebrew Year: Divide the total elapsed days by the average length of a Hebrew year (approx. 382.5 days, accounting for leap years) to estimate the Hebrew year.
Calculate Days within Hebrew Year: Subtract the days of previous full Hebrew years from the total elapsed days.
Determine Hebrew Month and Day: Iterate through the Hebrew months, subtracting their lengths (which depend on whether it's a leap year and potential postponements) until the remaining days correspond to the specific day within the current Hebrew month.
Variables Table:
Variable
Meaning
Unit
Typical Range
Gregorian Date (Gyear, Gmonth, Gday)
Input date in the Gregorian calendar.
Year, Month, Day
e.g., 2023, 10, 26
Hebrew Epoch
Reference point for Hebrew calendar (World Creation).
BCE Date
October 7, 3761 BCE
Days Elapsed (Dtotal)
Total number of days from Hebrew Epoch to Gregorian Date.
Days
Millions
Hebrew Year (Hyear)
The corresponding year in the Hebrew calendar.
Year
e.g., 5784
Hebrew Month (Hmonth)
The corresponding month in the Hebrew calendar.
Month Name/Number
1-13
Hebrew Day (Hday)
The corresponding day within the Hebrew month.
Day
1-30
Metonic Cycle
19-year cycle containing 7 leap years.
Cycle
1-19
Practical Examples (Real-World Use Cases)
Example 1: Finding the date of a holiday
Scenario: A person wants to know when Passover begins in the Gregorian year 2025. Passover always starts on the 15th of Nisan.
Input: Gregorian Date: March 25, 2025 (This is an approximation, the calculator will find the exact Hebrew date corresponding to the start of Nisan).
Calculator Process: The user inputs '2025-03-25'. The calculator determines that this date falls within the Hebrew month of Nisan in the year 5785.
Output:
Primary Result: Nisan 15, 5785
Hebrew Year: 5785
Hebrew Month: Nisan
Hebrew Day: 15
Parashah: (Varies, but the date itself is the key result)
Interpretation: The calculator confirms that the 15th of Nisan, 5785, corresponds to April 14, 2025, in the Gregorian calendar. This is the first day of Passover.
Example 2: Calculating a Yahrzeit
Scenario: Someone's grandmother passed away on the 10th of Tevet in the Hebrew year 5770. They want to know the Gregorian date for her Yahrzeit in 2024.
Input: The user needs to find the Gregorian date that corresponds to Tevet 10, 5770. This requires a reverse calculation (Hebrew to Gregorian), but our tool focuses on Gregorian to Hebrew. For this example, let's assume we know Tevet 10, 5770 was December 27, 2009.
Calculator Process: The user inputs '2024-12-17' (an approximate date for the Yahrzeit in 2024). The calculator finds the corresponding Jewish date.
Output:
Primary Result: Tevet 17, 5785
Hebrew Year: 5785
Hebrew Month: Tevet
Hebrew Day: 17
Parashah: (Varies)
Interpretation: The calculator shows that Tevet 17, 5785, corresponds to December 17, 2024. This is the date the Yahrzeit will be observed in 2024. The user can then plan accordingly.
How to Use This Jewish Date Calculator
Using the Gregorian to Jewish Date Calculator is straightforward. Follow these simple steps:
Enter the Gregorian Date: In the input field labeled "Gregorian Date", use the date picker to select the specific date (Year, Month, Day) you wish to convert.
Initiate Conversion: Click the "Convert Date" button.
View Results: The calculator will instantly display the corresponding Jewish date. This includes:
The full Jewish date (e.g., Nisan 15, 5785).
The Hebrew Year.
The Hebrew Month.
The Hebrew Day.
The weekly Torah portion (Parashah) for that Shabbat, if applicable.
Understand the Output: The primary result is the most prominent display of the Jewish date. The intermediate values provide a breakdown. The Parashah information is useful for those following the weekly Torah reading cycle.
Copy Results: If you need to use the converted date elsewhere, click the "Copy Results" button. This will copy the main Jewish date and key details to your clipboard.
Reset: To perform a new conversion, you can either clear the date field manually or click the "Reset" button to clear all fields and start over.
Decision-Making Guidance: This calculator is invaluable for planning religious observances, understanding historical Jewish events, or simply connecting with the Jewish calendar. Ensure you input the correct Gregorian date for accurate results.
Key Factors That Affect Jewish Date Results
While the conversion seems simple, several underlying factors influence the accuracy and structure of the Hebrew calendar, and thus the results of any Jewish date calculator:
Lunar Cycle Variations: The actual length of a lunar month varies slightly. The Hebrew calendar uses a calculated average, but precise astronomical observation was historically crucial.
Solar Year Alignment: The need to keep festivals in their seasons (e.g., Passover in spring) requires adjustments. This is managed by the 19-year Metonic cycle, adding a leap month (Adar I) 7 times within the cycle.
Leap Year Calculation: Determining which years in the 19-year cycle are leap years is critical. The sequence is fixed: 3, 6, 8, 11, 14, 17, 19.
Month Length Adjustments (Dechiyot): The lengths of Cheshvan and Kislev are adjusted (29 or 30 days) to prevent specific holidays from falling on Shabbat or adjacent days, ensuring proper observance. This is known as the "laws of postponement" (dechiyot).
Start of the Day: In the Jewish tradition, a day begins at sunset. While Gregorian dates are based on midnight, the calculation implicitly handles this transition.
Epoch Reference Point: The accuracy depends on the precise definition and calculation of the Hebrew calendar's epoch (the start date, traditionally the World Creation).
Gregorian Calendar Accuracy: The Gregorian calendar itself has undergone reforms (e.g., the switch from Julian). Modern calculators assume the current Gregorian system.
Frequently Asked Questions (FAQ)
Q1: Is the Jewish calendar the same as the Islamic calendar?
No. The Islamic calendar is purely lunar, meaning its holidays shift through all seasons over time. The Jewish calendar is lunisolar, incorporating solar adjustments to keep holidays in their traditional seasons.
Q2: Why does the Hebrew year number seem so high?
The Hebrew calendar counts years from a traditional calculation of the world's creation, placing it significantly earlier than the Gregorian calendar's epoch (based on the estimated birth of Jesus).
Q3: What is a leap month in the Hebrew calendar?
In a leap year (7 times in a 19-year cycle), an extra month called Adar I (אדר א) is added before the regular Adar (which then becomes Adar II, אדר ב). This keeps the lunar months aligned with the solar seasons.
Q4: How do I know if the year I'm converting to is a leap year?
A Hebrew year is a leap year if it is the 3rd, 6th, 8th, 11th, 14th, 17th, or 19th year in the 19-year Metonic cycle. The calculator handles this automatically.
Q5: Can this calculator convert Hebrew dates back to Gregorian?
This specific calculator is designed for Gregorian to Hebrew conversion. While the underlying principles are the same, a reverse calculator would require a different interface.
Q6: What does "Parashah" mean in the results?
Parashah refers to the weekly Torah portion read in synagogue. The calculator indicates which Parashah corresponds to the Shabbat of the calculated Jewish date.
Q7: Are there different types of Jewish calendars?
While the lunisolar calendar described is the standard, there have been historical variations and different traditions. This calculator uses the modern, fixed Hebrew calendar established by Hillel II.
Q8: How accurate are these calculators?
Modern Jewish date calculators are highly accurate, based on well-established algorithms derived from astronomical data and rabbinic tradition. They are reliable for all practical purposes.
Track the counting of the Omer between Passover and Shavuot.
// — Hebrew Calendar Conversion Logic —
// Based on algorithms for converting Gregorian to Hebrew dates.
// This is a simplified representation; full astronomical accuracy requires extensive libraries.
// Epoch for Hebrew Calendar (World Creation)
var HEBREW_EPOCH_YEAR = -3760; // Year before common era
var HEBREW_EPOCH_MONTH = 10; // Tishrei
var HEBREW_EPOCH_DAY = 7; // 7th day of Tishrei
// Month names (Hebrew and English approximation)
var hebrewMonths = [
{ name: "Nisan", he: "ניסן", days: 30, leapDays: 30 },
{ name: "Iyar", he: "אייר", days: 29, leapDays: 29 },
{ name: "Sivan", he: "סיון", days: 30, leapDays: 30 },
{ name: "Tammuz", he: "תמוז", days: 29, leapDays: 29 },
{ name: "Av", he: "אב", days: 30, leapDays: 30 },
{ name: "Elul", he: "אלול", days: 29, leapDays: 29 },
{ name: "Tishrei", he: "תשרי", days: 30, leapDays: 30 },
{ name: "Cheshvan", he: "חשון", days: 29, leapDays: 29 }, // Variable
{ name: "Kislev", he: "כסלו", days: 29, leapDays: 29 }, // Variable
{ name: "Tevet", he: "טבת", days: 29, leapDays: 29 },
{ name: "Shevat", he: "שבט", days: 30, leapDays: 30 },
{ name: "Adar I", he: "אדר א'", days: 0, leapDays: 30 }, // Leap year only
{ name: "Adar II", he: "אדר ב'", days: 29, leapDays: 29 } // Adar in standard, Adar II in leap
];
// Parashah data (simplified – requires a comprehensive list for full accuracy)
// This is a placeholder and would need a real dataset mapping dates to Parashot.
var parashot = [
"Bereishit", "Noach", "Lech-Lecha", "Vayera", "Chayei Sarah", "Toldot", "Vayetzei", "Vayishlach",
"Vayeshev", "Miketz", "Vayigash", "Vayechi", "Shemot", "Va'era", "Bo", "Beshalach",
"Yitro", "Mishpatim", "Terumah", "Tetzaveh", "Ki Tisa", "Vayakhel", "Pekudei",
"Vayikra", "Tzav", "Shemini", "Tazria", "Metzora", "Achrei Mot", "Kedoshim",
"Emor", "Behar", "Bechukotai", "Bamidbar", "Nasso", "Beha'alotecha", "Shelach",
"Korach", "Chukat", "Balak", "Pinchas", "Matot", "Masei", "Devarim",
"Va'etchanan", "Eikev", "Re'eh", "Shoftim", "Ki Teitzei", "Ki Tavo", "Nitzavim",
"Vayelech", "Ha'azinu", "Vezot Haberacha"
];
// Function to check if a Gregorian year is a leap year
function isGregorianLeap(year) {
return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
}
// Function to check if a Hebrew year is a leap year (based on 19-year cycle)
// HYear is the Hebrew year number (e.g., 5784)
function isHebrewLeap(hYear) {
var cyclePos = (hYear – 1) % 19; // 0-indexed position in the 19-year cycle
// Leap years are at positions 3, 6, 8, 11, 14, 17, 19 (which is 0 in 0-indexed)
return cyclePos === 2 || cyclePos === 5 || cyclePos === 7 || cyclePos === 10 || cyclePos === 13 || cyclePos === 16 || cyclePos === 0;
}
// Function to calculate days in a Hebrew year
function getHebrewYearLength(hYear) {
var leap = isHebrewLeap(hYear);
var baseLength = 354; // Standard year length
var adjustments = 0;
// Add days for leap month if applicable
if (leap) {
adjustments += hebrewMonths[11].leapDays; // Adar I
}
// Adjust Cheshvan and Kislev based on year type (regular, deficient, abundant)
// This requires knowing the specific year's type, which depends on complex calculations
// For simplicity, we'll use common defaults or assume a regular year.
// A full implementation would calculate the year type based on the day of week of Tishrei 1 and Pesach 15.
// Defaulting to regular year lengths for Cheshvan/Kislev (29 days each)
var cheshvanDays = hebrewMonths[7].days;
var kislevDays = hebrewMonths[8].days;
// Simplified adjustment logic (a real calculator needs more complex rules)
// Example: If year is 'deficient', Cheshvan=29, Kislev=29. If 'regular', Cheshvan=29, Kislev=30. If 'abundant', Cheshvan=30, Kislev=30.
// We'll assume 'regular' for this example.
if (hYear % 2 === 0) { // Simple heuristic for demonstration
kislevDays = 30;
} else {
kislevDays = 29;
}
if (hYear % 3 === 0) { // Another heuristic
cheshvanDays = 30;
} else {
cheshvanDays = 29;
}
return baseLength + adjustments + cheshvanDays + kislevDays;
}
// Function to get the number of days in a specific Hebrew month
function getHebrewMonthLength(hYear, hMonthIndex) {
var leap = isHebrewLeap(hYear);
if (hMonthIndex === 11) { // Adar I
return leap ? hebrewMonths[hMonthIndex].leapDays : 0;
}
if (hMonthIndex === 12) { // Adar II (or Adar in standard year)
return leap ? hebrewMonths[hMonthIndex].leapDays : hebrewMonths[10].days; // Adar II or regular Adar
}
if (hMonthIndex === 7) { // Cheshvan
// Simplified: Assume regular year length
return 29;
}
if (hMonthIndex === 8) { // Kislev
// Simplified: Assume regular year length
return 30;
}
return leap ? hebrewMonths[hMonthIndex].leapDays : hebrewMonths[hMonthIndex].days;
}
// Function to convert Gregorian date to Julian Day Number (JDN)
// JDN is a continuous count of days since noon Universal Time on January 1, 4713 BC.
function gregorianToJDN(year, month, day) {
month = month – 1; // Adjust month to be 0-indexed
var a = Math.floor((14 – month) / 12);
var y = year + 4800 – a;
var m = month + 12 * a – 3;
var jdn = day + Math.floor((153 * m + 2) / 5) + 365 * y + Math.floor(y / 4) – Math.floor(y / 100) + Math.floor(y / 400) – 32045;
return jdn;
}
// Function to convert Julian Day Number (JDN) to Gregorian date
function jdnToGregorian(jdn) {
var a = jdn + 32044;
var b = Math.floor((4 * a + 3) / 1461);
var c = a – Math.floor(1461 * b / 4);
var d = Math.floor((4 * c + 3) / 1461);
var year = 4 * b + d + 1;
var e = c – Math.floor(1461 * d / 4) + 31;
var m = Math.floor((8 * e + 10) / 25);
var month = m – Math.floor((12 * m) / 37);
var day = e – Math.floor((306 * m) / 10) + 1;
return { year: year, month: month, day: day };
}
// Main conversion function
function convertGregorianToHebrew(gYear, gMonth, gDay) {
var jdn = gregorianToJDN(gYear, gMonth, gDay);
// Calculate days from Hebrew epoch to Gregorian epoch
var epochJDN = gregorianToJDN(HEBREW_EPOCH_YEAR, HEBREW_EPOCH_MONTH, HEBREW_EPOCH_DAY);
var daysSinceEpoch = jdn – epochJDN;
// Estimate Hebrew year
var hYear = HEBREW_EPOCH_YEAR + Math.floor(daysSinceEpoch / 382.5); // Approx. avg year length
// Adjust Hebrew year until we find the correct one
while (true) {
var currentYearLength = getHebrewYearLength(hYear);
var prevYearLength = getHebrewYearLength(hYear – 1);
if (daysSinceEpoch >= prevYearLength && daysSinceEpoch < currentYearLength) {
// Found the correct Hebrew year
break;
} else if (daysSinceEpoch < prevYearLength) {
hYear–;
} else {
hYear++;
}
}
// Calculate days within the Hebrew year
var daysInPrevYears = daysSinceEpoch – getHebrewYearLength(hYear – 1);
// Determine Hebrew month and day
var hMonthIndex = 0;
var remainingDays = daysInPrevYears;
var currentMonthLength = 0;
while (hMonthIndex < 13) {
currentMonthLength = getHebrewMonthLength(hYear, hMonthIndex);
if (remainingDays < currentMonthLength) {
break; // Found the month
}
remainingDays -= currentMonthLength;
hMonthIndex++;
}
var hDay = remainingDays;
var hMonth = hMonthIndex;
// Adjust for Adar I/II naming
var finalHebrewMonthName = hebrewMonths[hMonth].name;
var finalHebrewMonthHe = hebrewMonths[hMonth].he;
if (hMonth === 11) finalHebrewMonthName = "Adar I";
if (hMonth === 12) finalHebrewMonthName = "Adar II";
// Get Parashah (simplified lookup)
var parashahIndex = (daysSinceEpoch – 1) % parashot.length; // Very basic, needs proper mapping
var currentParashah = parashot[parashahIndex];
return {
year: hYear,
monthIndex: hMonth,
monthName: finalHebrewMonthName,
monthHe: finalHebrewMonthHe,
day: hDay,
parashah: currentParashah
};
}
// — Charting Logic —
function drawHebrewCalendarChart() {
var canvas = document.getElementById('hebrewCalendarChart');
if (!canvas) return;
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear previous drawing
var chartWidth = canvas.width;
var chartHeight = canvas.height;
var barWidth = (chartWidth – 60) / 13; // Space for 13 bars + padding
var maxDays = 30; // Max days in a month
// Get current Hebrew year from input or default
var gregorianDateInput = document.getElementById('gregorianDate').value;
var currentHebrewYear = 5784; // Default
if (gregorianDateInput) {
var parts = gregorianDateInput.split('-');
var gYear = parseInt(parts[0], 10);
var gMonth = parseInt(parts[1], 10);
var gDay = parseInt(parts[2], 10);
var hebrewDateInfo = convertGregorianToHebrew(gYear, gMonth, gDay);
currentHebrewYear = hebrewDateInfo.year;
}
var isLeap = isHebrewLeap(currentHebrewYear);
var monthData = [];
var labels = [];
for (var i = 0; i < hebrewMonths.length; i++) {
var month = hebrewMonths[i];
var days = isLeap ? month.leapDays : month.days;
// Handle Adar I/II correctly
if (i === 11 && !isLeap) continue; // Skip Adar I if not leap
if (i === 12 && !isLeap) { // If not leap, Adar II is just Adar
monthData.push(hebrewMonths[10].days);
labels.push(hebrewMonths[10].name + " (" + hebrewMonths[10].he + ")");
} else {
monthData.push(days);
labels.push(month.name + " (" + month.he + ")");
}
}
// Scale the chart
var scale = (chartHeight – 40) / maxDays; // 40px for labels/padding
// Draw bars
ctx.fillStyle = '#004a99';
for (var i = 0; i < monthData.length; i++) {
var barHeight = monthData[i] * scale;
var x = 30 + i * barWidth;
var y = chartHeight – 10 – barHeight; // 10px for bottom padding
ctx.fillRect(x, y, barWidth – 10, barHeight); // Draw bar with spacing
}
// Draw labels
ctx.fillStyle = '#333';
ctx.font = '10px Arial';
ctx.textAlign = 'center';
for (var i = 0; i < labels.length; i++) {
var x = 30 + i * barWidth + (barWidth – 10) / 2;
ctx.fillText(labels[i], x, chartHeight – 5); // Bottom labels
}
// Draw Y-axis labels
ctx.textAlign = 'right';
for (var day = 0; day <= maxDays; day += 5) {
var y = chartHeight – 10 – (day * scale);
ctx.fillText(day.toString(), 25, y + 4); // Right align labels
}
ctx.fillText('Days', 25, chartHeight – 10 – (maxDays * scale) – 10); // Axis title
// Draw Title
ctx.font = 'bold 14px Arial';
ctx.fillText('Hebrew Calendar Year Overview (' + currentHebrewYear + ')', chartWidth / 2, 20);
}
// — Calculator UI Logic —
function validateInput(inputId, errorId, minDate, maxDate) {
var input = document.getElementById(inputId);
var errorElement = document.getElementById(errorId);
var value = input.value;
var isValid = true;
errorElement.style.display = 'none'; // Hide error initially
if (!value) {
errorElement.textContent = "This field is required.";
errorElement.style.display = 'block';
isValid = false;
} else {
var date = new Date(value);
if (isNaN(date.getTime())) {
errorElement.textContent = "Invalid date format.";
errorElement.style.display = 'block';
isValid = false;
} else if (minDate && date maxDate) {
errorElement.textContent = "Date cannot be after " + maxDate.toLocaleDateString() + ".";
errorElement.style.display = 'block';
isValid = false;
}
}
return isValid;
}
function calculateJewishDate() {
var gregorianDateInput = document.getElementById('gregorianDate');
var resultsContainer = document.getElementById('results-container');
var jewishDateResult = document.getElementById('jewishDateResult');
var hebrewYear = document.getElementById('hebrewYear');
var hebrewMonth = document.getElementById('hebrewMonth');
var hebrewDay = document.getElementById('hebrewDay');
var parashah = document.getElementById('parashah');
var isValid = true;
isValid = validateInput('gregorianDate', 'gregorianDateError');
if (!isValid) {
resultsContainer.style.display = 'none';
return;
}
var dateValue = gregorianDateInput.value;
var parts = dateValue.split('-');
var gYear = parseInt(parts[0], 10);
var gMonth = parseInt(parts[1], 10);
var gDay = parseInt(parts[2], 10);
try {
var hebrewDateInfo = convertGregorianToHebrew(gYear, gMonth, gDay);
jewishDateResult.textContent = hebrewDateInfo.monthHe + " " + hebrewDateInfo.day + ", " + hebrewDateInfo.year;
hebrewYear.textContent = hebrewDateInfo.year;
hebrewMonth.textContent = hebrewDateInfo.monthName + " (" + hebrewDateInfo.monthHe + ")";
hebrewDay.textContent = hebrewDateInfo.day;
parashah.textContent = hebrewDateInfo.parashah;
resultsContainer.style.display = 'block';
drawHebrewCalendarChart(); // Update chart
} catch (e) {
console.error("Calculation error:", e);
jewishDateResult.textContent = "Error calculating date.";
resultsContainer.style.display = 'block';
}
}
function resetCalculator() {
document.getElementById('gregorianDate').value = ";
document.getElementById('gregorianDateError').textContent = ";
document.getElementById('gregorianDateError').style.display = 'none';
document.getElementById('jewishDateResult').textContent = ";
document.getElementById('hebrewYear').textContent = ";
document.getElementById('hebrewMonth').textContent = ";
document.getElementById('hebrewDay').textContent = ";
document.getElementById('parashah').textContent = ";
document.getElementById('results-container').style.display = 'none';
drawHebrewCalendarChart(); // Redraw with default/empty state
}
function copyResults() {
var mainResult = document.getElementById('jewishDateResult').textContent;
var hebrewYear = document.getElementById('hebrewYear').textContent;
var hebrewMonth = document.getElementById('hebrewMonth').textContent;
var hebrewDay = document.getElementById('hebrewDay').textContent;
var parashah = document.getElementById('parashah').textContent;
var gregorianDate = document.getElementById('gregorianDate').value;
var textToCopy = "Gregorian Date: " + gregorianDate + "\n" +
"Jewish Date: " + mainResult + "\n" +
"Hebrew Year: " + hebrewYear + "\n" +
"Hebrew Month: " + hebrewMonth + "\n" +
"Hebrew Day: " + hebrewDay + "\n" +
"Parashah: " + parashah;
navigator.clipboard.writeText(textToCopy).then(function() {
var feedback = document.getElementById('copyFeedback');
feedback.style.display = 'block';
setTimeout(function() {
feedback.style.display = 'none';
}, 2000);
}).catch(function(err) {
console.error('Failed to copy text: ', err);
});
}
// Initial chart draw on load
window.onload = function() {
drawHebrewCalendarChart();
};