Last active
November 27, 2017 09:28
-
-
Save klashxx/8034c89056568f9bfae11c2ef8214816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // requires moment.js | |
| var getWeekEndDays = function (year) { | |
| return new Promise(function (resolve, reject) { | |
| if (year === undefined) { | |
| year = moment().year().toString() | |
| } | |
| let weekEndsDays = [] | |
| let start = moment(year + '-01-01').startOf('year') | |
| let end = moment(year + '-01-01').endOf('year') | |
| for (var day = moment(start); day.isBefore(end); day.add(1, 'days')) { | |
| if (day.weekday() === 6 || day.weekday() === 0) { | |
| weekEndsDays.push(day.toDate()) | |
| } | |
| } | |
| resolve(weekEndsDays) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment