gcal-events JS not displaying the correct label

19 views Asked by At

I have a website using this JS code:

http://www.codehandling.com/2013/05/myevents-your-google-calendar-events.html

Here is the homepage of my website: http://emeraldislebarandgrill.com/

You will see the first box says Feb 28th and then says Monday Specials, when I display the GMT date it is the correct date but its the label that is not displaying correctly, I believe it has to do with the fact that its Leap year this year, but how do I adjust the JS code to account for a leap year.

Here is a function that I believe needs to be adjusted in the gcal-events.js file (http://emeraldislebarandgrill.com/js/gcal-events.js):

function getDateLowerLimit() {
var todayDate;
if (dateLowerlimit == "") {

    todayDate = new Date();

    dateLowerlimit = todayDate.getFullYear() + "-" + (todayDate.getMonth() + 1) + "-" + (todayDate.getDate() < 10 ? '0' : '') + todayDate.getDate() + "T00:00:00+00:00";
} else {
    todayDate = new Date(dateLowerlimit)
}

}

1

There are 1 answers

0
Alpdog14 On

So it seemed that the easiest route at this point, was to just add 1 to the getDate variable when it was getting outputting.

(dd.getDate()+1)

if (withZone) return "<span class='gcal-datetime'>" + monthNames[dd.getMonth()] + " " + (dd.getDate()+1) + " " + hours + ":" + (dd.getMinutes() < 10 ? '0' : '') + dd.getMinutes() + " " + ampm + "</span><br/><span class='gcal-tzone'>" + timeZone + "</span>";
return monthNames[dd.getMonth()] + " " + dd.getDate() + " " + hours + ":" + (dd.getMinutes() < 10 ? '0' : '') + dd.getMinutes() + " " + ampm

If anyone knows the correct way to detect a leap year in the gcal-events.js I would love to do this correctly instead of this hack because next year I will have to update it again and then again in 4 years.