Here you can find the source of yearStartDay()
Date.prototype.yearStartDay = function(){ return new Date(this.getFullYear(),0,1).getDay(); }
Date.prototype.isThisYear = function() { return new Date().getYear() == this.getYear(); };
Date.prototype.subYears = function(value) { var month = this.getMonth(); this.setFullYear(this.getFullYear() - value); if (month < this.getMonth()) { this.setDate(0); return this; };
Date.prototype.toYearEnd = function () { var date = new Date(this); date.setMonth(12); date.setDate(0); return date; };
Date.prototype.toYearStart = function () { var date = new Date(this); date.setMonth(0); date.setDate(1); return date; };
Date.prototype.weekOfYear = function () { var year = this.getFullYear(); var d = new Date(this); d.setHours(0, 0, 0, 0); var yearStart = new Date(year, 0, 1); d.setDate(d.getDate() + yearStart.getDay()); var deltaDay = (d.getTime() - yearStart.getTime()) / 86400000 + 1; var weekNo = Math.ceil(deltaDay / 7); return [year, weekNo]; ...