// Weeks function WeeklySpreadsheet(start, key) { this.start = new Date(start); this.key = key; this.setTitle = () => { let end = addDays(this.start, 6); let monthsArr = new Months().short; return monthsArr[this.start.getMonth()] + ' ' + this.start.getDate() + ' — ' + monthsArr[end.getMonth()] + ' ' + end.getDate(); }; this.createAnchor = purpose => { let title = this.setTitle(), text = ''; let active = new Date().getTime() >= this.start.getTime(); let anchor = '' + ((active) ? text + '' : '' + text); return anchor; }; } // Assistance function Months() { this.short = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; // this.long = [ // 'January', 'February', 'March', // 'April', 'May', 'June', // 'July', 'August', 'September', // 'October', 'November', 'December' // ]; } function addDays(date, days) { return new Date(date.getTime() + days * 24 * 60 * 60 * 1000); }