Skip to content

Instantly share code, notes, and snippets.

@earnubs
Created March 29, 2019 20:31
Show Gist options
  • Save earnubs/6cefefe43b963ede4bcfd5dc4c090884 to your computer and use it in GitHub Desktop.
Save earnubs/6cefefe43b963ede4bcfd5dc4c090884 to your computer and use it in GitHub Desktop.
date-fns, days of month
const df = require('date-fns');
const today = Date.now();
const tomorrow = df.addDays(today, 1);
function getWorkDaysInMonth(day) {
return df.eachDay(df.startOfMonth(day), df.endOfMonth(day))
.filter(date => !df.isWeekend(date))
.map(date => df.format(date, 'ddd Do'));
}
console.log(getWorkDaysInMonth(today).length);
console.log(getWorkDaysInMonth(tomorrow).length);
/*
$('.btn-link[type="button"]')[0].click();
$('textarea[placeholder="Type or click to select an item."]')[0].click()
$('.ac-option.active a').click()
$('textarea.item-description[name="Consultancy"]')[0].value = "XXX date";
*/
{
"name": "try-month",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"date-fns": "^1.29.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment