Code:
<script>
'use strict';
/* Adapted from Java Script Calendar the credit for which is preserved here - adaptation (c)2017 John Davenport Scheuer
as first seen in http://www.dynamicdrive.com/forums/
username: jscheuer1 - This Notice Must Remain for Legal Use */
/* Original script: http://www.javascriptkit.com/script/script2/chdate.shtml
Java Script Calendar is a small script for web pages which displays current Day of the week, Month, Date and Year along with Holidays notification. Just like this working demo below. It will work with Netscape 2++, Microsoft 3++ and Opera 3++ web browsers.
Tuesday, November 24, 1998
About 70 holidays from all over the world are displayed by Calendar (if you know other ones, let me know, I will add them). It even calculates Easter Sunday date! To see how it works change the date on your computer to January, 1,
for example and re-load the page.*/
(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(), cd = 25, gfmonth, dhtml = [],
dayname = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], gfdate, wmmonth, wmdate, admonth, addate, sd,
monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"], stcal = new Date(),
html = [dayname[day], ", ", monthname[month], " ", date < 10? "0" : "", date, ", ", year], thanksdate = new Date(), stmonth, stdate, adnames;
gfwmcal.setMonth(--emonth);
gfwmcal.setDate(edate - 2);
gfmonth = gfwmcal.getMonth();
gfdate = gfwmcal.getDate();
gfwmcal.setDate(gfdate + 52);
wmmonth = gfwmcal.getMonth();
wmdate = gfwmcal.getDate();
stcal.setMonth(emonth);
stcal.setDate(edate - 49);
sd = stcal.getDate();
stcal.setDate(sd + 2 - stcal.getDay());
stmonth = stcal.getMonth();
stdate = stcal.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);
// Easter and Related
if (month === emonth && date === edate) dhtml.push("Easter Sunday (Western)");
if (month === gfmonth && date === gfdate) dhtml.push("Good Friday (Western)");
if (month === wmmonth && date === wmdate) dhtml.push("Whit Monday");
if (month === stmonth && date === stdate) dhtml.push("Shrove Tuesday");
// Advent
if (month === admonth && date === addate) dhtml.push("Advent Sunday");
adnames = ['Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth', 'Tenth', 'Eleventh', 'Twelfth'];
for(i = 0; i < adnames.length; ++i){
adcal.setDate(addate + 1);
if (month === adcal.getMonth() && date === (addate = adcal.getDate())) dhtml.push("Today is the " + adnames[i] + " Day of Advent");
}
[function(){ // January
if (date === 1) dhtml.push("New Year's Day");
if (date === 27) dhtml.push("Wolfgang Amadeus Mozart born (1756)");
if (day === 1 && date > 14 && date < 22) dhtml.push("Martin Luther King's Birthday");
},
function(){ // February
if (date === 2) dhtml.push("Groundhog Day");
if (date === 8) dhtml.push("Jules Verne born (1828)");
if (date === 11) dhtml.push("National Foundation Day (Japan)");
if (date === 12) dhtml.push("Lincoln's Birthday");
if (date === 14) dhtml.push("St. Valentine's Day");
if (date === 15) dhtml.push("Galileo Galilei born (1564)");
if (date === 22) dhtml.push("Washington's Birthday");
if (day == 0 && date > 0 && date < 8) document.write("Daylight Saving Time Begins (UK)");
if (date === 29) dhtml.push("Leap Day");
},
function(){ // March
if (date === 1) dhtml.push("St Davids Day");
if (date === 17) dhtml.push("St. Patrick's Day");
if (date === 21) dhtml.push("First day of Spring");
},
function(){ // April
if (date === 1) dhtml.push("April Fools' Day");
if (date === 15 && day !== 0 && day !== 6) dhtml.push("Income Tax Day (USA)");
if ((date === 16 || date === 17) && day === 1) dhtml.push("Income Tax Day (USA)");
if (date === 15) dhtml.push("Leonardo da Vinci born (1452)");
if (date === 23) dhtml.push("St Georges day");
},
function(){ // May
if (date === 1) dhtml.push("May Day");
if (day === 1 && date > 24) dhtml.push("Memorial Day");
},
function(){ // June
if (date === 21) dhtml.push("Summer Solstice");
if (day === 0 && date > 15 && date < 24) dhtml.push("Father's Day");
},
function(){ // July
if (date === 1) dhtml.push("Independence Day (Canada)");
if (date === 4) dhtml.push("Independence Day (USA)");
},
function(){ // August
},
function(){ // September
if (date === 16) dhtml.push("Independence Day (Mexico)");
if (day== 1 && date > 0 && date < 8) dhtml.push("Labor Day (USA)");
},
function(){ // October
if (date === 1) dhtml.push("4 weeks to Halloween");
if (date === 8) dhtml.push("It's 23 days to Halloween");
if (date === 9) dhtml.push("It's 22 days to Halloween");
if (day === 0 && date > 24 && date < 31) dhtml.push("GMT begins today");
if (day === 0 && date === 31) dhtml.push("GMT begins today<BR>");
if (date === 10) dhtml.push("It's 21 days to Halloween");
if (date === 11) dhtml.push("It's 20 days to Halloween");
if (date === 12) dhtml.push("It's 19 days to Halloween");
if (date === 13) dhtml.push("It's 18 days to Halloween");
if (date === 14) dhtml.push("It's 17 days to Halloween");
if (date === 15) dhtml.push("It's 16 days to Halloween");
if (date === 16) dhtml.push("It's 15 days to Halloween");
if (date === 17) dhtml.push("It's 14 days to Halloween");
if (date === 18) dhtml.push("It's 13 days to Halloween");
if (date === 19) dhtml.push("It's 12 days to Halloween");
if (date === 20) dhtml.push("It's 11 days to Halloween");
if (date === 21) dhtml.push("It's 10 days to Halloween");
if (date === 22) dhtml.push("It's 9 days to Halloween");
if (date === 23) dhtml.push("It's 8 days to Halloween");
if (date === 24) dhtml.push("It's 7 days to Halloween");
if (date === 25) dhtml.push("It's 6 days to Halloween");
if (date === 26) dhtml.push("It's 5 days to Halloween");
if (date === 27) dhtml.push("It's 4 days to Halloween");
if (date === 28) dhtml.push("It's 3 days to Halloween");
if (date === 29) dhtml.push("It's 2 days to Halloween");
if (date === 30) dhtml.push("1 day to go it's Halloween tomorrow");
if (date === 31) dhtml.push("It's Halloween");
},
function(){ // November
if (day === 0 && date < 8) dhtml.push("Daylight Saving Time Ends (most of USA)");
if (date === 1) dhtml.push("All Saints Day");
if (date === 2) dhtml.push("All Souls Day");
if (date === 5) dhtml.push("Guy Fawkes day");
if (date === 11) dhtml.push("Armistice Day");
if (date === 24) dhtml.push("It will Christmas Eve four weeks from today");
if (date === 25) dhtml.push("It will be Christmas Day four weeks from today");
if (date === 27) dhtml.push ("Christmas is coming!");
if (date === thanksdate) dhtml.push("Thanksgiving (USA)");
},
function(){ // December
if (date === 9) dhtml.push("Today is Human Rights Day");
if (date === 13) dhtml.push("It's 12 days to Christmas");
if (date === 14) dhtml.push("It's 11 days to Christmas");
if (date === 15) dhtml.push("It's 10 days to Christmas");
if (date === 16) dhtml.push("It's 9 days to Christmas");
if (date === 17) dhtml.push("It's 8 days to Christmas");
if (date === 18) dhtml.push("It's 7 days to Christmas");
if (date === 19) dhtml.push("It's 6 days to Christmas");
if (date === 20) dhtml.push("It's just 5 days to Christmas");
if (date === 21) dhtml.push("Winter Solstice the shortest day and 4 days to Christmas");
if (date === 22) dhtml.push("Christmas is nearly here, just 2 more days");
if (date === 23) dhtml.push("It's Christmas Eve tommorrow almost time to party!");
if (date === 24) dhtml.push("Christmas Eve a Merry Christmas from Wytoretro");
if (date === 25) dhtml.push("Christmas Day a Merry Christmas from Wytonsite");
if (date === 26) dhtml.push("Boxing Day a Merry Christmas from the Wytonsite");
if (date === 27) dhtml.push("Saturday");
if (date === 31) dhtml.push("Today is New Year's Eve Happy New Year");
}][month]();
document.getElementById('datecontainer2').innerHTML = dhtml.join('<br>');
if(linebreak){document.getElementById('datecontainer2').appendChild(document.createElement('br'));}
})();
</script>
I've also set it up, so that if there's more than one event, any additional events for a given day will have a linebreak first, as I think that's what you want with this particular feature. The other one (first one with all those long events), just adds a comma and a space before additional events, which seems right for it. In fact, you might want to consider removing Christmas, Easter, etc. from the first version of the script on the page there as those events will only be repeated in the second date feature.
Bookmarks