I am simply trying to get this function to work when I run it in script editor. Gives the error:
Cannot find function getYear in object [object Object].
I have tried the same with getFullYear
but to no avail. Strangely, when I put it inside another larger function that has nothing to do with it, it seems to work perfectly. On its own, it gives that error. Here is the code:
function WeekNumber() {
Date.prototype.getWeek = function() {
var onejan = new Date(this.getYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}
var currentTime = new Date();
return new currentTime.getWeek()
}