
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
moment-business
Advanced tools
Utilities for working with week days and weekend days in Moment. It assumes a Western workweek, in which weekends are Saturday and Sunday.
Looking for a vanilla JS version of this library? Check out bizniz.js
Moment is an indispensable tool for working with dates in Javascript, but it doesn't supply methods for working with week days or weekend days (at least, not yet).
This library supplies you with those missing tools.
There are alternative libraries for these methods, but this one uses constant-time algorithms, not loops. Loops are easier for a human to write, but are much slower for a computer to resolve.
Install this library through npm.
npm install moment-business
Next, import it into your project.
import business from 'moment-business';
business.isWeekDay(someMoment);
Note: this library is also available through Bower.
weekDays( startMoment, endMoment )
Calculate the number of week days between startMoment
and endMoment
. Week days are Monday through Friday.
If endMoment
comes before startMoment
, then this function will return a negative value.
weekendDays( startMoment, endMoment )
Calculate the number of weekend days between the moment and otherMoment
. Weekend days are Saturday and Sunday.
If endMoment
comes before startMoment
, then this function will return a negative value.
addWeekDays( moment, amount )
Add week days to a moment, modifying the original moment. Returns the moment.
subtractWeekDays( moment, amount )
Subtract week days from the moment, modifying the original moment. Returns the moment.
isWeekDay( moment )
Whether or not the Moment is a week day (Monday - Friday).
isWeekendDay( moment )
Whether or not the Moment occurs on Saturday or Sunday.
window.none
. Now it is available
under window.momentBusiness
. Note that this issue does not affect users
building with ES2015/CommonJS/AMD module bundlers.FAQs
Methods to work with week days and weekends in moment.
The npm package moment-business receives a total of 25,325 weekly downloads. As such, moment-business popularity was classified as popular.
We found that moment-business demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.