JSFiddle - React, Tailwind, and code Playground
by dledle2
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ramadan & Passover Calculator</title>
<style>
body { font-family: sans-serif; padding: 1rem; max-width: 600px; margin: auto; }
label, input, button { display: block; margin: .5rem 0; }
#results { margin-top: 1rem; padding: 1rem; border: 1px solid #ccc; }
</style>
</head>
<body>
<h1>Ramadan 1 & Passover 15 Nisan Calculator</h1>
<label for="yearInput">Enter a year (–3000 to 50000):</label>
<input id="yearInput" type="number" value="2025" min="-3000" max="50000">
<button id="calcBtn">Calculate</button>
<div id="results">
<p><strong>Ramadan 1:</strong> <span id="ramadan"></span></p>
<p><strong>Passover 15 Nisan:</strong> <span id="passover"></span></p>
</div>
<script>
// ——— Julian Day Number ↔ Gregorian ———
function gregorianToJd(y, m, d) {
// extends to any integer y
if (m <= 2) { y--; m += 12; }
const A = Math.floor(y/100);
const B = 2 - A + Math.floor(A/4);
return Math.floor(365.25*(y + 4716))
+ Math.floor(30.6001*(m + 1))
+ d + B - 1524.5;
}
function jdToGregorian(jd) {
let Z = Math.floor(jd + 0.5);
let F = (jd + 0.5) - Z;
let A = Z;
if (Z >= 2299161) {
const alpha = Math.floor((Z - 1867216.25)/36524.25);
A += 1 + alpha - Math.floor(alpha/4);
}
const B = A + 1524;
const C = Math.floor((B - 122.1)/365.25);
const D = Math.floor(365.25*C);
const E = Math.floor((B - D)/30.6001);
const day = B - D - Math.floor(30.6001*E) + F;
let month = (E < 14 ? E - 1 : E - 13);
let year = (month > 2 ? C - 4716 : C - 4715);
return { year, month, day: Math.floor(day) };
}
// ——— Tabular Islamic (arithmetical) ———
// Epoch: 1 Muharram 1 AH = Julian day 1948439.5
const ISLAMIC_EPOCH = 1948439.5;
function islamicToJd(year, month, day) {
return day
+ Math.ceil(29.5*(month - 1))
+ (year - 1)*354
+ Math.floor((3 + 11*year)/30)
...