Skip to content

Instantly share code, notes, and snippets.

@earnubs

earnubs/index.js

Created Mar 29, 2019
Embed
What would you like to do?
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