1. Junior Coders
Join Date
Dec 2017
Posts
15
Thanks
0
Thanked 0 Times in 0 Posts

## adding more dates e.g. good friday

1) Script Title: date function

2) Script URL (on DD): http://www.javascriptkit.com/script/...2/chdate.shtml

3) Describe problem: How can I add extra dates for example, Good Friday, Easter Monday, and whit Monday for example using the "edate" function as shown here:

Code:
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year < 1000)
year+=1900
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var monthname =
new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );

document.write("<b><font face=Arial size=3 font color=white>   ");
// Easter
if ((month == emonth) && (date == edate)) document.write("Easter Sunday (Western)   ");
Last edited by jscheuer1; 12-05-2017 at 11:55 AM. Reason: format code

2. Easter, Good Friday, and Whit Monday are different each year, and I'm not certain one can trust the calculation used in this code. Apparently they all work off of each other though, so theoretically, if you can calculate one, the other two should be easy enough to find. I would be tempted to just set them like the other fixed dates in the calender, and just update them every year. But assuming that the calculation for Easter is correct (which it is for 2017 and 2018 anyway), and that Good Friday is 2 days before, Whit Monday 50 days after:

Code:
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
gfwmcal = 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();
var dayname = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var monthname =
new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );
document.write("");
document.write(dayname[day] + ", ");
document.write(monthname[month] + " ");
if (date< 10) document.write("0" + date + ", ");
else document.write(date + ", ");
document.write(year + "    ");
// Easter and related
if ((month == emonth) && (date == edate)) document.write("Easter Sunday (Western)   ");
if ((month == gfmonth) && (date == gfdate)) document.write("Good Friday (Western)   ");
if ((month == wmmonth) && (date == wmdate)) document.write("Whit Monday   ");
// January
if ((month == 0) && (date == 1)) documen . . .
Last edited by jscheuer1; 12-05-2017 at 12:59 PM. Reason: tested 2018 as well

3. Junior Coders
Join Date
Dec 2017
Posts
15
Thanks
0
Thanked 0 Times in 0 Posts
Thank you for your prompt response to my question. I am very grateful for your help and advice. I shall have a play with it and see what happens, and I will report back when I have done this. Once again thank you very much.
leccie

4. OK. I looked into this Easter date calculation bit more. It appears to be standard and valid to like 2099 or something like that. I kind of cringed though at the overall code, both inefficient and prone to conflicts. Here's an updated version. Slight change, you need to make a "datecontainer" (included in this demo). Also, if you don't want there to be a line break after the date, remove the highlighted line (near the end):

Code:
<!DOCTYPE html>
<html>
<title>Java Script Calendar - demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<body>
<span id="datecontainer"></span>
<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 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, gfmonth, gfdate, wmmonth, wmdate,
dayname = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"],
html = [dayname[day], ", ", monthname[month], " ", date < 10? "0" : "", date, ", ", year, "    "];
--emonth;
gfwmcal = 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();
// Easter and Related
if ((month == emonth) && (date == edate)) html.push("Easter Sunday (Western)   ");
if ((month == gfmonth) && (date == gfdate)) html.push("Good Friday (Western)   ");
if ((month == wmmonth) && (date == wmdate)) html.push("Whit Monday   ");
// January
if ((month == 0) && (date == 1)) html.push("New Year's Day");
if ((month == 0) && (date == 15)) html.push("Adults Day (Japan)");
if ((month == 0) && (date == 27)) html.push("Wolfgang Amadeus Mozart born (1756)");
if ((month == 0) && (day == 1) && (date > 14) && (date< 22)) html.push("Martin Luther King's Birthday");
// February
if ((month == 1) && (date == 2)) html.push("Groundhog Day");
if ((month == 1) && (date == 8)) html.push("Jules Verne born (1828)");
if ((month == 1) && (date == 11)) html.push("National Foundation Day (Japan)");
if ((month == 1) && (date== 12)) html.push("Lincoln's Birthday");
if((month == 1) && (date == 14)) html.push("St. Valentine's Day");
if ((month == 1) && (date == 15)) html.push("Galileo Galilei born (1564)");
if ((month == 1) && (date == 22)) html.push("Washington's Birthday");
if ((month == 1) && (date == 29)) html.push("Leap Day");
// March
if ((month == 2) && (date == 3)) html.push("Girl's Day (Japan)");
if ((month == 2) && (date == 17)) html.push("St. Patrick's Day");
if ((month == 2) && (date == 21)) html.push("J.S. Bach born (1685)");
// April
if ((month == 3) && (date == 1)) html.push("April Fools' Day");
if ((month == 3) && (date == 8)) html.push("Buddha born");
if ((month == 3) && (date == 15) && (day != 0)) html.push("Income Tax Day (USA),   ");
if ((month == 3) && (date == 16) && (day == 1)) html.push("Income Tax Day (USA) ");
if ((month == 3) && (date == 15)) html.push("Leonardo da Vinci born (1452)");
if ((month == 3) && (date == 22)) html.push("Earth Day");
if ((month == 3) && (date == 29)) html.push("Emperor's Birthday (Japan)");
if ((month == 3) && (day == 0) && (date > 0) && (date< 8)) html.push("Daylight Savings Time Begins");
// May
if ((month == 4) && (date == 1)) html.push("May Day,   Boy's Day (Japan)");
if ((month == 4) && (date == 2)) html.push("Constitution Day (Japan)");
if ((month == 4) && (date == 5)) html.push("Cinco de Mayo (Mexico),   Children's Day (Japan)");
if ((month == 4) && (date == 14)) html.push("Independence Day (Paraguay)");
if ((month == 4) && (day == 0) && (date > 7) && (date< 16)) html.push("Mother's Day");
if ((month == 4) && (day == 1) && (date > 24)) html.push("Memorial Day");
// June
if ((month == 5) && (date == 5)) html.push("Constitution Day (Denmark)");
if ((month == 5) && (date == 6)) html.push("D-Day (USA)");
if ((month == 5) && (date == 11)) html.push("Kamehameha (Hawaii)");
if ((month == 5) && (date == 14)) html.push("FlagDay (USA)");
if ((month == 5) && (date == 21)) html.push("Summer Solstice");
if((month == 5) && (date == 24)) html.push("St. Jean Baptiste Day (Canada)");
if ((month == 5) && (date == 30)) html.push("Independence Day (Zaire)");
if ((month == 5) && (day == 0) && (date > 15) && (date< 24)) html.push("Father's Day");
// July
if ((month == 6) && (date == 1)) html.push("Independence Day (Canada)");
if ((month == 6) && (date == 4)) html.push("Independence Day (USA)");
if ((month == 6) && (date == 14)) html.push("Bastille Day (France)");
// August
if ((month == 7) && (date == 1)) html.push("Confederation Day (Switzerland)");
if ((month == 7) && (date == 10)) html.push("Independence Day (Ecuador)");
if ((month == 7) && (date == 15)) html.push("Independence Day (India)");
// September
if ((month == 8) && (date == 7)) html.push("Independence Day (Brazil)");
if ((month == 8) && (date == 15)) html.push("Respect for the Aged Day (Japan)");
if ((month == 8) && (date == 16)) html.push("Independence Day (Mexico)");
if ((month == 8) && (day== 1)&& (date > 0) && (date< 8)) html.push("Labor Day (USA)");
// October
if ((month == 9) && (date == 1)) html.push("German Reunufication (1990)");
if ((month == 9) && (date == 10)) html.push("Health-Sports Day (Japan)");
if ((month == 9) && (day == 1) && (date > 7) && (date< 16)) html.push("Columbus Day (USA)");
if ((month == 9) && (day == 0) && (date > 24) && (date< 31)) html.push("Daylight Savings Time Ends");
if ((month == 9) && (day == 0) && (date == 31)) html.push("Daylight Savings Time Ends<BR>");
if ((month == 9) && (date == 24)) html.push("United Nations Day");
if ((month == 9) && (date == 31)) html.push("Halloween");
// November
if ((month == 10) && (date == 1)) html.push("All Saints Day");
if ((month == 10) && (date == 2)) html.push("All Souls Day");
if ((month == 10) && (date == 3)) html.push("Culture Day (Japan)");
if ((month == 10) && (date == 11)) html.push("Veteran's Day (USA),    Remembrance Day (Canada)");
if ((month == 10) && (date ==20)) html.push("Revolution Day (Mexico)");
if ((month == 10) && (date == 23)) html.push("Labor Thanksgiving Day (Japan)");
if ((month == 10) && (day == 4) && (date > 23) && (date< 30)) html.push("Thanksgiving (USA)");
if ((month == 10) && (date == 30) && (day == 4)) html.push("Thanksgiving (USA)");
// December
if ((month == 11) && (date == 10)) html.push("Human Rights Day");
if ((month == 11) && (date == 21)) html.push("Winter Solstice");
if ((month == 11) && (date == 24)) html.push("Christmas Eve");
if ((month == 11) && (date == 25)) html.push("Christmas");
if ((month == 11) && (date == 26)) html.push("Boxing Day");
if ((month == 11) && (date == 31)) html.push("New Year's Eve");
html.push("<br>");
document.getElementById('datecontainer').innerHTML = html.join('');
})();
</script>

</body>
</html>
Last edited by jscheuer1; 12-05-2017 at 10:41 PM. Reason: add good to 2099

5. Junior Coders
Join Date
Dec 2017
Posts
15
Thanks
0
Thanked 0 Times in 0 Posts
Hi John, I find this all very challenging, and very fascinating, to say the least. I have studied how you have set the dates to be called up, and have attempted to replicate what you have done so that I can also call up the first day of Advent. There must be 4 Sundays before Christmas. Therefore, Advent could occur in the last week of November or the first week of December. If you would be kind enough to look at what I have tried to do would you explain what I have done wrong, and how to do it correctly? This is what I have done. but it does not work.

Code:
(function(){
var 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, gfmonth, gfdate, wmmonth, wmdate, advmonth,
dayname = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"],
html = [dayname[day], ", ", monthname[month], " ", date < 10? "0" : "", date, ", ", year, "    "];
--emonth;
gfwmcal = 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();
gfwmcal.setDate (gfdate + 236);
// Easter and Related
if ((month == emonth) && (date == edate)) html.push("Easter Sunday (Western)   ");
if ((month == gfmonth) && (date == gfdate)) html.push("Good Friday (Western)   ");
if ((month == wmmonth) && (date == wmdate)) html.push("Whit Monday   ");
Last edited by jscheuer1; 12-06-2017 at 01:26 PM. Reason: format code

6. Junior Coders
Join Date
Dec 2017
Posts
15
Thanks
0
Thanked 0 Times in 0 Posts
I have referenced what I am was trying to do here: https://www.staff.science.uu.nl/~gen...ter_text2c.htm But because the amount of days between Easter Sunday and Advent are not fixed it would seem that there is no datum to work from.
John

7. Junior Coders
Join Date
Dec 2017
Posts
15
Thanks
0
Thanked 0 Times in 0 Posts
A thought occurs to me. Christmas day is a fixed date, so could Advent Sunday be calculated from the 25th of December?

8. Sure, it can be easily worked out from Christmas:

Code:
var adcal = new Date(), cd = 25; //Xmas day
}
adcal.setDate(cd - 28); // go back 4 weeks
}
That's the basic idea. Here it is integrated into the calendar function:

Code:
<!DOCTYPE html>
<html>
<title>Java Script Calendar - demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<body>
<span id="datecontainer"></span>
<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 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, gfmonth, gfdate, wmmonth, wmdate, adcal, admonth, addate,
dayname = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], cd = 25,
monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"],
html = [dayname[day], ", ", monthname[month], " ", date < 10? "0" : "", date, ", ", year, "    "];
--emonth;
gfwmcal = 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();
}
// Easter and Related
if ((month == emonth) && (date == edate)) html.push("Easter Sunday (Western)   ");
if ((month == gfmonth) && (date == gfdate)) html.push("Good Friday (Western)   ");
if ((month == wmmonth) && (date == wmdate)) html.push("Whit Monday   ");
// January
if ((month == 0) && (date == 1)) html.push("New Year's Day");
if ((month == 0) && (date == 15)) html.push("Adults Day (Japan)");
if ((month == 0) && (date == 27)) html.push("Wolfgang Amadeus Mozart born (1756)");
if ((month == 0) && (day == 1) && (date > 14) && (date< 22)) html.push("Martin Luther King's Birthday");
// February
if ((month == 1) && (date == 2)) html.push("Groundhog Day");
if ((month == 1) && (date == 8)) html.push("Jules Verne born (1828)");
if ((month == 1) && (date == 11)) html.push("National Foundation Day (Japan)");
if ((month == 1) && (date== 12)) html.push("Lincoln's Birthday");
if((month == 1) && (date == 14)) html.push("St. Valentine's Day");
if ((month == 1) && (date == 15)) html.push("Galileo Galilei born (1564)");
if ((month == 1) && (date == 22)) html.push("Washington's Birthday");
if ((month == 1) && (date == 29)) html.push("Leap Day");
// March
if ((month == 2) && (date == 3)) html.push("Girl's Day (Japan)");
if ((month == 2) && (date == 17)) html.push("St. Patrick's Day");
if ((month == 2) && (date == 21)) html.push("J.S. Bach born (1685)");
// April
if ((month == 3) && (date == 1)) html.push("April Fools' Day");
if ((month == 3) && (date == 8)) html.push("Buddha born");
if ((month == 3) && (date == 15) && (day != 0)) html.push("Income Tax Day (USA),   ");
if ((month == 3) && (date == 16) && (day == 1)) html.push("Income Tax Day (USA) ");
if ((month == 3) && (date == 15)) html.push("Leonardo da Vinci born (1452)");
if ((month == 3) && (date == 22)) html.push("Earth Day");
if ((month == 3) && (date == 29)) html.push("Emperor's Birthday (Japan)");
if ((month == 3) && (day == 0) && (date > 0) && (date< 8)) html.push("Daylight Savings Time Begins");
// May
if ((month == 4) && (date == 1)) html.push("May Day,   Boy's Day (Japan)");
if ((month == 4) && (date == 2)) html.push("Constitution Day (Japan)");
if ((month == 4) && (date == 5)) html.push("Cinco de Mayo (Mexico),   Children's Day (Japan)");
if ((month == 4) && (date == 14)) html.push("Independence Day (Paraguay)");
if ((month == 4) && (day == 0) && (date > 7) && (date< 16)) html.push("Mother's Day");
if ((month == 4) && (day == 1) && (date > 24)) html.push("Memorial Day");
// June
if ((month == 5) && (date == 5)) html.push("Constitution Day (Denmark)");
if ((month == 5) && (date == 6)) html.push("D-Day (USA)");
if ((month == 5) && (date == 11)) html.push("Kamehameha (Hawaii)");
if ((month == 5) && (date == 14)) html.push("FlagDay (USA)");
if ((month == 5) && (date == 21)) html.push("Summer Solstice");
if((month == 5) && (date == 24)) html.push("St. Jean Baptiste Day (Canada)");
if ((month == 5) && (date == 30)) html.push("Independence Day (Zaire)");
if ((month == 5) && (day == 0) && (date > 15) && (date< 24)) html.push("Father's Day");
// July
if ((month == 6) && (date == 1)) html.push("Independence Day (Canada)");
if ((month == 6) && (date == 4)) html.push("Independence Day (USA)");
if ((month == 6) && (date == 14)) html.push("Bastille Day (France)");
// August
if ((month == 7) && (date == 1)) html.push("Confederation Day (Switzerland)");
if ((month == 7) && (date == 10)) html.push("Independence Day (Ecuador)");
if ((month == 7) && (date == 15)) html.push("Independence Day (India)");
// September
if ((month == 8) && (date == 7)) html.push("Independence Day (Brazil)");
if ((month == 8) && (date == 15)) html.push("Respect for the Aged Day (Japan)");
if ((month == 8) && (date == 16)) html.push("Independence Day (Mexico)");
if ((month == 8) && (day== 1)&& (date > 0) && (date< 8)) html.push("Labor Day (USA)");
// October
if ((month == 9) && (date == 1)) html.push("German Reunufication (1990)");
if ((month == 9) && (date == 10)) html.push("Health-Sports Day (Japan)");
if ((month == 9) && (day == 1) && (date > 7) && (date< 16)) html.push("Columbus Day (USA)");
if ((month == 9) && (day == 0) && (date > 24) && (date< 31)) html.push("Daylight Savings Time Ends");
if ((month == 9) && (day == 0) && (date == 31)) html.push("Daylight Savings Time Ends<BR>");
if ((month == 9) && (date == 24)) html.push("United Nations Day");
if ((month == 9) && (date == 31)) html.push("Halloween");
// November
if ((month == 10) && (date == 1)) html.push("All Saints Day");
if ((month == 10) && (date == 2)) html.push("All Souls Day");
if ((month == 10) && (date == 3)) html.push("Culture Day (Japan)");
if ((month == 10) && (date == 11)) html.push("Veteran's Day (USA),    Remembrance Day (Canada)");
if ((month == 10) && (date ==20)) html.push("Revolution Day (Mexico)");
if ((month == 10) && (date == 23)) html.push("Labor Thanksgiving Day (Japan)");
if ((month == 10) && (day == 4) && (date > 23) && (date< 30)) html.push("Thanksgiving (USA)");
if ((month == 10) && (date == 30) && (day == 4)) html.push("Thanksgiving (USA)");
// December
if ((month == 11) && (date == 10)) html.push("Human Rights Day");
if ((month == 11) && (date == 21)) html.push("Winter Solstice");
if ((month == 11) && (date == 24)) html.push("Christmas Eve");
if ((month == 11) && (date == 25)) html.push("Christmas");
if ((month == 11) && (date == 26)) html.push("Boxing Day");
if ((month == 11) && (date == 31)) html.push("New Year's Eve");
html.push("<br>");
document.getElementById('datecontainer').innerHTML = html.join('');
})();
</script>

</body>
</html>
Last edited by jscheuer1; 12-06-2017 at 05:31 PM. Reason: adjust highlighting, later minor code improvement

9. Junior Coders
Join Date
Dec 2017
Posts
15
Thanks
0
Thanked 0 Times in 0 Posts
Well, another issue has arisen. When your revised script is added to the page nothing appears! Having spent a while looking at what could be the cause of this, it is, I suspect because the font description is not referenced. This how it appears it the original Script:

new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );

document.write("<b><font face=Arial size=3 font color=white> ");
// Easter
if ((month == emonth) && (date == edate)) document.write("Easter Sunday (Western) ");
// January

Now am I right in thinking this is due to the document.write function being replaced by html.push? So, how should the font be referenced in the re-coded version. I have tried several different approaches but without success.

10. Font is deprecated. document.write is deprecated. I'm using innerHTML, which requires a receiving element*:

Code:
<span id="datecontainer"></span>
Make sure that appears on your page before this script. Place it where you want the date to appear.

Working demo:

http://jscheuer1.com/demos/tidbits/dates.htm

If you want to modify the appearance of the text of the date, you can do it using style (any questions on that part, let me know).

If it's still not working, please post a link to the page on your site that shows the problem.

The page may need to be reloaded, and/or the browser cache cleared to see changes.

* I mentioned this before, but didn't stress it. I thought you would just follow the example I provided. Sorry.

Edit: The more I look at this, the more I see issues. I've just updated it to accurately reflect current DST changes, Tax day and Thanksgiving, and make it more consistent syntactically, changes also uploaded to my live demo:

Code:
<!DOCTYPE html>
<html>
<title>Java Script Calendar - demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<body>
<span id="datecontainer"></span>
<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)
var 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,
monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"], td = 1,
html = [dayname[day], ", ", monthname[month], " ", date < 10? "0" : "", date, ", ", year], thanksdate = new Date(), thanks = 0;
--emonth;
gfwmcal.setMonth(emonth);
gfwmcal.setDate(edate - 2);
gfmonth = gfwmcal.getMonth();
gfdate = gfwmcal.getDate();
gfwmcal.setDate(gfdate + 52);
wmmonth = gfwmcal.getMonth();
wmdate = gfwmcal.getDate();
thanksdate.setMonth(10);
thanksdate.setDate(1);
if(thanksdate.getDay() === 4) {++thanks;}
while(thanks !== 4){thanksdate.setDate(++td); if(thanksdate.getDay() === 4){++thanks;}}
thanksdate = thanksdate.getDate();
// 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 === 0){ // January
if (date === 1) dhtml.push("New Year's Day");
if (date === 15) dhtml.push("Adults Day (Japan)");
if (date === 27) dhtml.push("Wolfgang Amadeus Mozart born (1756)");
if (day === 1 && date > 14 && date < 22) dhtml.push("Martin Luther King's Birthday");
}
if (month === 1){ // 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 (date === 29) dhtml.push("Leap Day");
}
if (month === 2){ // March
if (date === 3) dhtml.push("Girl's Day (Japan)");
if (day === 0 && date > 7 && date < 15) dhtml.push("Daylight Saving Time Begins (most of USA)");
if (date === 17) dhtml.push("St. Patrick's Day");
if (date === 21) dhtml.push("J.S. Bach born (1685)");
}
if (month === 3){ // April
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 === 1) dhtml.push("April Fools' Day");
if (date === 8) dhtml.push("Buddha born");
if (date === 15) dhtml.push("Leonardo da Vinci born (1452)");
if (date === 22) dhtml.push("Earth Day");
if (date === 29) dhtml.push("Emperor's Birthday (Japan)");
}
if (month === 4){ // May
if (date === 1) dhtml.push("May Day, Boy's Day (Japan)");
if (date === 2) dhtml.push("Constitution Day (Japan)");
if (date === 5) dhtml.push("Cinco de Mayo (Mexico), Children's Day (Japan)");
if (date === 14) dhtml.push("Independence Day (Paraguay)");
if (day === 0 && date > 7 && date < 16) dhtml.push("Mother's Day");
if (day === 1 && date > 24) dhtml.push("Memorial Day");
}
if (month === 5){ // June
if (date === 5) dhtml.push("Constitution Day (Denmark)");
if (date === 6) dhtml.push("D-Day (USA)");
if (date === 11) dhtml.push("Kamehameha (Hawaii)");
if (date === 14) dhtml.push("FlagDay (USA)");
if (date === 21) dhtml.push("Summer Solstice");
if (date === 24) dhtml.push("St. Jean Baptiste Day (Canada)");
if (date === 30) dhtml.push("Independence Day (Zaire)");
if (day === 0 && date > 15 && date < 24) dhtml.push("Father's Day");
}
if (month === 6){ // July
if (date === 1) dhtml.push("Independence Day (Canada)");
if (date === 4) dhtml.push("Independence Day (USA)");
if (date === 14) dhtml.push("Bastille Day (France)");
}
if (month === 7){ // August
if (date === 1) dhtml.push("Confederation Day (Switzerland)");
if (date === 10) dhtml.push("Independence Day (Ecuador)");
if (date === 15) dhtml.push("Independence Day (India)");
}
if (month === 8){ // September
if (date === 7) dhtml.push("Independence Day (Brazil)");
if (date === 15) dhtml.push("Respect for the Aged Day (Japan)");
if (date === 16) dhtml.push("Independence Day (Mexico)");
if (day === 1 && date > 0 && date < 8) dhtml.push("Labor Day (USA)");
}
if (month === 9){ // October
if (date === 1) dhtml.push("German Reunufication (1990)");
if (date === 10) dhtml.push("Health-Sports Day (Japan)");
if (day === 1 && date > 7 && date < 16) dhtml.push("Columbus Day (USA)");
if (date === 24) dhtml.push("United Nations Day");
if (date === 31) dhtml.push("Halloween");
}
if (month === 10){ // 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 === 3) dhtml.push("Culture Day (Japan)");
if (date === 11) dhtml.push("Veteran's Day (USA), Remembrance Day (Canada)");
if (date === 20) dhtml.push("Revolution Day (Mexico)");
if (date === thanksdate) dhtml.push("Thanksgiving (USA)");
if (date === 23) dhtml.push("Labor Thanksgiving Day (Japan)");
}
if (month === 11){ // December
if (date === 10) dhtml.push("Human Rights Day");
if (date === 21) dhtml.push("Winter Solstice");
if (date === 24) dhtml.push("Christmas Eve");
if (date === 25) dhtml.push("Christmas");
if (date === 26) dhtml.push("Boxing Day");
if (date === 31) dhtml.push("New Year's Eve");
}
document.getElementById('datecontainer').innerHTML = html.join('') + (dhtml.length? ' - ' + dhtml.join(', ') : '');
if(linebreak){document.getElementById('datecontainer').appendChild(document.createElement('br'));}
})();
</script>

</body>
</html>
Last edited by jscheuer1; 12-07-2017 at 04:02 AM. Reason: add info, code improvement

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•