This script is displaying the Maunday Thursday notification incorrectly. (see screen shot) and try as I might I cannot sort it out. It should display just “Maunday Thursday” Can anyone suggest why this might be happening, and what I can to do rectify it
(function () {
var linebreak = true, // should line break be added after date and holidays (if any) (true/false)
calendar = new Date(),
day = calendar.getDay(),
month = calendar.getMonth(),
date = calendar.getDate(),
year = calendar.getFullYear(),
f = Math.floor, cent = f(year / 100),
g = year % 19,
k = f((cent - 17) / 25),
i = (cent - f(cent / 4) - f((cent - k) / 3) + 19 * g + 15) % 30,
i = i - f(i / 28) * (1 - f(i / 28) * f(29 / (i + 1)) * f((21 - g) / 11)),
j = (year + f(year / 4) + i + 2 - cent + f(cent / 4)) % 7, l = i - j,
emonth = 3 + f((l + 40) / 44),
edate = l + 28 - 31 * f((emonth / 4)),
gfwmcal = new Date(),
adcal = new Date(),
shrcal = new Date(),
cd = 25,
gfmonth, dhtml = [],
dayname = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
gfdate, wmmonth, wmdate, admonth, addate,
monthname = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
html = [dayname[day], ", ", monthname[month], " ", date < 10 ? "0" : "", date, ", ", year], thanksdate = new Date();
gfwmcal.setMonth(--emonth);
gfwmcal.setDate(edate - 2);
gfmonth = gfwmcal.getMonth();
gfdate = gfwmcal.getDate();
gfwmcal.setDate(gfdate + 52);
wmmonth = gfwmcal.getMonth();
wmdate = gfwmcal.getDate();
adcal.setMonth(11);
adcal.setDate(cd);
if (adcal.getDay()) { cd += (7 - adcal.getDay()); }
adcal.setDate(cd - 28);
admonth = adcal.getMonth();
addate = adcal.getDate();
thanksdate.setMonth(10);
thanksdate.setDate(1);
thanksdate = 5 - thanksdate.getDay();
thanksdate += (thanksdate < 1 ? 28 : 21);
// Shrove tuesday
// Set date to easter - 47 days:
shrcal.setMonth(emonth);
shrcal.setDate(edate - 47);
console.log(shrcal);
shroveMonth = shrcal.getMonth();
shroveDate = shrcal.getDate();
// Lent
var
currentDate = new Date(year, month, date),
// The day after Shrove tuesday
lentStartCal = new Date(year, shroveMonth, shroveDate + 1),
// Two days before easter sundy
lentEndCal = new Date(year, emonth, edate - 2);
console.log(currentDate, lentStartCal, lentEndCal);
// Maunday Thursday
// 3 days before easter sunday:
var
maundayThursday = new Date(year, emonth, edate - 3);
console.log( maundayThursday);
// Easter and Related
if (month === shroveMonth && date === shroveDate) dhtml.push("Shrove Saturday<p></p>");
if (currentDate >= lentStartCal && currentDate < lentEndCal) dhtml.push("Ash Wedensday first day of Lent");
if (currentDate.toString() === maundayThursday.toString() ) dhtml.push("Maunday Thursday (Pancake Day)<p></p>");
if (month === emonth && date === edate) dhtml.push("Easter Sunday (Western)<p></p>");
if (month === gfmonth && date === gfdate) dhtml.push("Good Friday (Western)<p></p>");
if (month === wmmonth && date === wmdate) dhtml.push("Whit Monday<p></p>");