Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: adding more dates e.g. good friday

  1. #11
    Join Date
    Dec 2017
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Just tried to submit page code but it was rejected because it was to many characters. Unfortunately it is still not working. Right now the site is not up on the web because my ISP has just discontinued hosting. So, before going to a new host I thought I would take the opportunity to to some major updating.

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,407
    Thanks
    77
    Thanked 3,432 Times in 3,393 Posts
    Blog Entries
    12

    Default

    That's OK. The main thing is that you include the target element as I've explained. Do you understand what I said about that? Assuming there's nothing else causing the problem, that will fix it.

    In any case, I've been tweaking the code some more, and probably will continue to do so. You can always see my latest version here:

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

    Use the browser's "view source" (usually CTRL + U) to see the code. And if you have any further questions, or requests for dates, just let me know. This is still a very simple script to use. So even if I cannot see your page, we can probably get it working for you.

    You could attach a zip version of your file to a message here, or if you prefer, I can PM you my email address and you could attach it to an email message. Don't put code directly into an email though, it will get messed up.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #13
    Join Date
    Dec 2017
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Not quite sure about how to attach file. It would be more simple for me if you sent me your PM.

  4. #14
    Join Date
    Dec 2017
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default zip file page code

    The attached file is the code for the web page in its original form.
    Attached Files Attached Files

  5. #15
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,407
    Thanks
    77
    Thanked 3,432 Times in 3,393 Posts
    Blog Entries
    12

    Default

    OK, looks like a ton of stuff you got there, especially in the first of the two of the calendar scripts. Anyways, I've updated you to the latest code, so should make any future changes you'd like easier for us to work out between us:

    ww_update.zip

    I've got a question though, you have (October):

    Code:
     if ((month == 9) && (day == 0) && (date > 24) && (date< 31)) document.write("GMT begins today");
     if ((month == 9) && (day == 0) && (date == 31)) document.write("GMT begins today<BR>");
    What is that supposed to mean? GMT is always on, or are you in Europe somewhere near the prime meridian and you are trying to say it's the end of Daylight Saving Time? If so, I'm not sure that's accurate. At least in the US, we keep it much longer than that now, not sure what they do in other places. I've left it in for October (converted to the new way of showing things like that):

    Code:
    		if (day === 0 && date > 24 && date < 31) dhtml.push("GMT begins today");
    		if (day === 0 && date === 31) dhtml.push("GMT begins today<BR>");
    But I'd like to know your thinking on this. I also removed from April:

    Code:
     if ((month == 3) && (day == 0) && (date > 0) && (date< 8)) document.write("Daylight Saving Time Begins (North America)");
    Because, here at least we do it earlier, I think all of North America does, not sure. Replacing it with, for March (again, in the new syntax):

    Code:
    		if (day === 0 && date > 7 && date < 15) dhtml.push("Daylight Saving Time Begins (most of USA)");
    Where are you? That would help me figure this out, but at the same time, if your users are from all over the world, it might be best to skip announcements of time changes altogether, as they vary depending upon location, even within the US, and certainly by hemisphere as well as by nation. Then again, if you expect your users to be mostly from a certain locale, we could do the one for it and note it as such.

    Any other new dates, questions, or problems, let me know.

    Oh, and I think your nth Day of Advent might be off. We can fix that. Is Advent Sunday considered the 1st Day of Advent? And do you only want to cover the first 12 days (as in the 12 days of Christmas, perhaps) of Advent? I ask because that's the latest day of Advent you have featured in the code you sent me. I have to admit not being up on Advent and how it may be viewed by anyone with more specific knowledge of it than I have.
    Last edited by jscheuer1; 12-08-2017 at 02:46 AM. Reason: ask about Advent, later - another Advent question, then slight improvement to attached file
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #16
    Join Date
    Dec 2017
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John I live in the UK. O.K. to answer some of you questions. Advent as far as I am aware always starts on a Sunday, and there are 4 Sundays in Advent, so depending on what day Christmas day falls the first Sunday of Advent could occur in either November or December. Because of the influence of Advent calenders I always assumed that Advent started on the first day of December and that it was a fixed date, I have since discovered that this is not so. The start of Advent is in fact a moveable event and is 4 Sundays. I am not really concerned about when it ends only with being able to set when it starts. I would guess that Advent finishes on the fourth Sunday. British daylight saving begins on the last Sunday of March and ends on the last Sunday of October. I would also like to include Shrove Tuesday (pancake day) which is a pretty big deal over here. Shrove Tuesday is seven weeks before Easter Sunday which falls on the last Tuesday in February I think. Any how it is a moveable date that is tied in to when Easter Sunday occurs. I think that it signifies the beginning of Lent but I am not to sure about that. None of this is essential, but I think that it adds a nice touch to the opening page.
    John

  7. #17
    Join Date
    Dec 2017
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Not sure how complex this makes it, but I came across this on the internet. Shrove Tuesday is linked to Easter, so its date changes on an annual basis. The date can vary from as early as February 3rd to as late as March 9th. So, it seems I was yet again wrong in my presumption that Shrove Tuesday always falls on the last Tuesday of February.

  8. #18
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,407
    Thanks
    77
    Thanked 3,432 Times in 3,393 Posts
    Blog Entries
    12

    Default

    In that case you may want to put things back the way they were with the beginning of Daylight Saving Time, except label it as UK instead of as US or whatever (think you had it as North America in what you sent me, I changed it to US). As long as Shrove Tuesday works off of Easter, we can put it in the Easter and Related section, I'll have that in a few minutes. I'm still not clear about Advent. You could have it so that the first day of Advent gets mentioned as Advent Sunday (we already have that), and we could each subsequent day of Advent, up to 12? gets mentioned as Second Day of Advent, Third Day of Advent, and so on instead of how you have it now, which you say was assuming Dec 1st as the First Day. That won't take long to do, but if you want that, I need to know how many Days of Advent to go up to, 12? More?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #19
    Join Date
    Dec 2017
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think that an advent count down in days will be difficult to achieve, impossible in fact I would say, because Advent Sunday varies if I have interpreted it correctly, irrespective of which Sunday Advent is. Advent finishes on Christmas so the amount of days in Advent will be different each year. Take a look here http://catholic-resources.org/Lectio...iew-Advent.htm I think that will give a much clearer explanation than I can. If it is to complex don't bother. Advent Sunday will be just fine. If the US day light saving is the same as the UK then it would be nice to display that too. If it is different it would still be good to include US day light saving.

  10. #20
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,407
    Thanks
    77
    Thanked 3,432 Times in 3,393 Posts
    Blog Entries
    12

    Default

    Advent is easy to do, I've already done it. It's just a matter of how many days of it you want. Right now I have twelve. If you stop at twelve, there's no danger of running over. I suppose one could have 28 though (the maximum), but then you would have to break out of the loop on Christmas, so as not to go over. I have it set as a loop, tested and it works:

    Code:
    	// 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");
    	}
    This works off the fact that we already calculated Advent for the current year. If one wanted to run all the way to Christmas, one could just make testing for the month being equal to 11 and the date being equal to 25 as a signal to break out of the loop. If you want to have the maximum, the question arises as to whether or not Christmas is the nth day of Advent, or if Advent is over on Christmas. Let me know if you want the max, it will be easy to add, and, if so, if Christmas (the 25th) is included or if the 24th of Dec is the last Advent day.

    I've added Shrove Tuesday as well, that was actually a little harder. Since you only want these for the second date thing on that page, I've updated that for you and switched it back to UK time changes (also only involved in this second date feature):

    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.

    Let me know about Advent - if you want more than 12 days of it, and, if so, when it should stop. One other thing, if Advent and its days are to be the last of two or more events if more than one occur on a given day, I can arrange that. Right now the Advent events will always come before others if there are more than one on a given day.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Replies: 3
    Last Post: 03-04-2013, 12:25 AM
  2. different dates
    By james438 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-09-2010, 06:35 AM
  3. Friday the 13th
    By magicyte in forum The lounge
    Replies: 4
    Last Post: 03-14-2009, 02:12 AM
  4. Friday 13th
    By Sikky in forum The lounge
    Replies: 26
    Last Post: 11-07-2006, 08:17 AM
  5. Dates
    By NXArmada in forum PHP
    Replies: 10
    Last Post: 05-22-2006, 05:11 PM

Bookmarks

Posting Permissions

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