Created
March 29, 2019 20:31
-
-
Save earnubs/6cefefe43b963ede4bcfd5dc4c090884 to your computer and use it in GitHub Desktop.
date-fns, days of month
This file contains 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
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"; | |
*/ |
This file contains 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
{ | |
"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