помогите разобраться, куда и как добавить/отнять дни чтобы получить нужные даты которые ещё не высчитаны...
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<style>
div { width: 360px; border: 1px solid #a9a9a9; border-radius: 7px/5px; padding: 5px; margin-bottom: 3px; }
#information { border: none; padding: 0; }
input { display: inline-block; text-align: center; border: 1px solid #a9a9a9; }
</style>
</head>
<body>
<div>
<form name="UserInput">
<input id="yearEntry" name="YearEntry" type="number" min="326" max="4099" step="1" value="">
<input id="button1" name="button1" onclick="ShowEasters(UserInput.YearEntry.value)" type="button" value="Расcчитать">
</form>
</div>
<div id="information">
</div>
<script>
window.onload = function() { ShowEasters(document.getElementById('yearEntry').value); }
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var d = new Date();
document.querySelector('#yearEntry').value = d.getFullYear();
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var d = new Date();
document.querySelector('#yearEntry').value = d.getFullYear();
});
</script>
<script language="JavaScript" type="text/javascript">
var jDay = 0;
var jMonth = 0;
var oDay = 0;
var oMonth = 0;
var wDay = 0;
var wMonth = 0;
var year = 0;
if(parseFloat(navigator.appVersion) < 2) alert("You may need to upgrade your browser to reliably use the Easter Date calculator");
function ShowEasters(yr) {
year = parseInt(yr, 10);
if(isNaN(year))
year = 0;
jDay = 0;
jMonth = 0;
oDay = 0;
oMonth = 0;
wDay = 0;
wMonth = 0;
if(year <= 325 || year > 4099) document.getElementById('information').innerHTML = "<div>Введите год с 326 до 4099</div>";
else {
EasterJulian(); // used for all calculations
if(year > 325 && year <= 1583) {
document.getElementById('information').innerHTML = "<div>Католическая и православная пасха:<br> "
+ dateR_P(year, GetMonth(jMonth), GetOrdinal(jDay)) + " (по старому стилю)</div>";
} else {
EasterOrthodox(year, jDay, jMonth);
EasterWestern();
if(year <= 1923) {
document.getElementById('information').innerHTML = "<div>Католическая пасха:<br> "
+ dateR(year, GetMonth(wMonth), GetOrdinal(wDay))
+ "</div><div>Православная пасха:<br> "
+ dateR(year, GetMonth(oMonth), GetOrdinal(oDay))
// + " (по григорианскому календарю), эта дата в юлианском календаре "
+ "<br>" + dateR_P(year, GetMonth(jMonth), GetOrdinal(jDay)) + " (по старому стилю).</div>"
+ "<div>Масленица:<br>минус 49 дней от православной пасхи.</div>" +
"<div>Вербное воскресенье:<br>минус 7 дней от православной пасхи.</div>" +
"<div>Радуница:<br>плюс 9 дней к православной пасхе.</div>";
} else {
document.getElementById('information').innerHTML = "<div>Католическая пасха:<br>"
+ dateR(year, GetMonth(wMonth), GetOrdinal(wDay))
+ "</div><div>Православная пасха:<br>"
+ dateR(year, GetMonth(oMonth), GetOrdinal(oDay))
+ " <br> " + dateR_P(year, GetMonth(jMonth), GetOrdinal(jDay)) + " (по старому стилю).</div> "
+ "<div>Масленица:<br>минус 49 дней от православной пасхи.</div>" +
"<div>Вербное воскресенье:<br>минус 7 дней от православной пасхи.</div>" +
"<div>Радуница:<br>плюс 9 дней к православной пасхе.</div>";
}
}
}
}
function IntDiv(num, dvsr) {
var negate = false;
var result = 0;
if(dvsr == 0) return null;
else {
if(num * dvsr < 0 ) negate = true;
if(num < 0) num = -num;
if(dvsr < 0) dvsr = -dvsr;
result = ((num - (num % dvsr)) / dvsr);
if(negate) return -result;
else return result;
}
}
function GetMonth(m) {
if(m == 3) return 2;
if(m == 4) return 3;
if(m == 5) return 4;
}
function GetOrdinal(d) {
var rmdr = 0;
rmdr = d % 10;
if(d >= 4 && d <= 20 || rmdr == 0 || rmdr > 3) return d;
else {
if(rmdr == 1) return d;
if(rmdr == 2) return d;
if(rmdr == 3) return d;
}
}
function EasterJulian() {
var g = 0;
var i = 0;
var j = 0;
var p = 0;
g = year % 19;
i = (19 * g + 15) % 30;
j = (year + IntDiv(year, 4) + i) % 7;
p = i - j + 28;
jDay = p;
jMonth = 4;
if(p > 31) jDay = p - 31;
else jMonth = 3;
}
function EasterWestern() {
var g = 0;
var c = 0;
var h = 0;
var i = 0;
var j = 0;
var p = 0;
g = year % 19;
c = IntDiv(year, 100);
h = (c - IntDiv(c, 4) - IntDiv(8 * c + 13, 25) + 19 * g + 15) % 30;
i = h - IntDiv(h, 28) * (1 - IntDiv(h, 28)
* IntDiv(29, h + 1) * IntDiv(21 - g, 11));
j = (year + IntDiv(year, 4) + i + 2 - c + IntDiv(c, 4)) % 7;
p = i - j + 28;
wDay = p;
wMonth = 4;
if(p > 31) wDay = p - 31;
else wMonth = 3;
}
function EasterOrthodox (yr, jDay, jMonth) {
var extra = 0;
var tmp = 0;
oDay = 0;
oMonth = 0;
if(yr > 1582 && yr <= 4099) {
extra = 10;
if(yr > 1600) {
tmp = IntDiv(yr, 100) - 16;
extra = extra + tmp - IntDiv(tmp, 4);
}
oDay = jDay + extra;
oMonth = jMonth;
if(oMonth == 3 && oDay > 31) {
oMonth = 4;
oDay = oDay - 31;
}
if(oMonth == 4 && oDay > 30) {
oMonth = 5; oDay = oDay - 30;
}
}
}
function dateR(parYear, parMonth, parDate) {
var copyDate = new Date(parYear, parMonth, parDate);
var dayOfTheWeek = copyDate.getDay();
var date = (copyDate.getDate() < 10) ? "0" + copyDate.getDate() : copyDate.getDate();
var month = copyDate.getMonth();
var year = copyDate.getFullYear();
if(dayOfTheWeek == 0) dayOfTheWeek = "Воскресенье";
else if(dayOfTheWeek == 1) dayOfTheWeek = "Понедельник";
else if(dayOfTheWeek == 2) dayOfTheWeek = "Вторник";
else if(dayOfTheWeek == 3) dayOfTheWeek = "Среда";
else if(dayOfTheWeek == 4) dayOfTheWeek = "Четверг";
else if(dayOfTheWeek == 5) dayOfTheWeek = "Пятница";
else if(dayOfTheWeek == 6) dayOfTheWeek = "Суббота";
if(month == 0) month = "января";
else if(month == 1) month = "февраля";
else if(month == 2) month = "марта";
else if(month == 3) month = "апреля";
else if(month == 4) month = "мая";
else if(month == 5) month = "июня";
else if(month == 6) month = "июля";
else if(month == 7) month = "августа";
else if(month == 8) month = "сентября";
else if(month == 9) month = "октября";
else if(month == 10) month = "ноября";
else if(month == 11) month = "декабря";
return dayOfTheWeek
+ "<br>" + date + " " + month + " " + year + " г.";
}
function dateR_P(parYear, parMonth, parDate) {
var copyDate = new Date(parYear, parMonth, parDate);
var dayOfTheWeek = copyDate.getDay();
var date = (copyDate.getDate() < 10) ? "0" + copyDate.getDate() : copyDate.getDate();
var month = copyDate.getMonth();
var year = copyDate.getFullYear();
if(dayOfTheWeek == 0) dayOfTheWeek = "Воскресенье";
else if(dayOfTheWeek == 1) dayOfTheWeek = "Понедельник";
else if(dayOfTheWeek == 2) dayOfTheWeek = "Вторник";
else if(dayOfTheWeek == 3) dayOfTheWeek = "Среда";
else if(dayOfTheWeek == 4) dayOfTheWeek = "Четверг";
else if(dayOfTheWeek == 5) dayOfTheWeek = "Пятница";
else if(dayOfTheWeek == 6) dayOfTheWeek = "Суббота";
if(month == 0) month = "января";
else if(month == 1) month = "февраля";
else if(month == 2) month = "марта";
else if(month == 3) month = "апреля";
else if(month == 4) month = "мая";
else if(month == 5) month = "июня";
else if(month == 6) month = "июля";
else if(month == 7) month = "августа";
else if(month == 8) month = "сентября";
else if(month == 9) month = "октября";
else if(month == 10) month = "ноября";
else if(month == 11) month = "декабря";
return date + " " + month + " " + year + " г.";
}
</script>
</body>
</html>