Skip to content

Instantly share code, notes, and snippets.

@klashxx
Last active November 27, 2017 09:28
Show Gist options
  • Select an option

  • Save klashxx/8034c89056568f9bfae11c2ef8214816 to your computer and use it in GitHub Desktop.

Select an option

Save klashxx/8034c89056568f9bfae11c2ef8214816 to your computer and use it in GitHub Desktop.
// 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