New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

moment-business-days

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-business-days - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

29

index.js

@@ -48,19 +48,22 @@ 'use strict';

moment.fn.businessDiff = function(param) {
var end = this.clone();
var start = moment(param);
var daysBetween = 0;
moment.fn.businessDiff = function (param) {
var d1 = this.clone();
var d2 = param.clone();
var start = d1 < d2 ? d1 : d2;
var end = d2 > d1 ? d2 : d1;
if(start === end){
return daysBetween;
}
var daysBetween = 0;
while (start < end){
if(this.isBusinessDay(start)){
daysBetween++;
}
start = start.businessAdd(1)
if (start === end) {
return daysBetween;
}
while (start < end) {
if (start.isBusinessDay()) {
daysBetween++;
}
start.add(1, 'd')
}
return daysBetween;
return daysBetween;
};

@@ -67,0 +70,0 @@

{
"name": "moment-business-days",
"version": "1.0.2",
"version": "1.0.3",
"description": "MomentJS plugin to use business days ",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -73,2 +73,3 @@ # moment-business-days

**businessAdd(days)**

@@ -75,0 +76,0 @@

@@ -12,3 +12,3 @@ 'use strict';

describe('Moment Business Days', function () {
afterEach(resetLocale);

@@ -65,3 +65,3 @@ describe('.prevBusinessDay', function () {

expect(moment('2014-12-25').isBusinessDay()).to.be.false;
expect(moment('2015-12-25').isBusinessDay()).to.be.false;
expect(moment('2015-12-25').isBusinessDay()).to.be.false;
expect(callCount).to.equal(4);

@@ -108,6 +108,6 @@ done();

afterEach(resetLocale);
describe('On Wednesday, September 23rd 2015', function () {
it('should be 17 when there are no holidays', function (done) {
moment.updateLocale('us',{

@@ -177,2 +177,6 @@ workingWeekdays: null

});
it('...and in reverse order', function(){
var diff = moment('05-08-2017', 'MM-DD-YYYY').businessDiff(moment('05-15-2017','MM-DD-YYYY'))
expect(diff).to.eql(5)
});
it('Should calculate nr of business days with custom workingdays', function(){

@@ -184,3 +188,10 @@ moment.updateLocale('us',{

expect(diff).to.eql(6)
})
});
it('Should calculate nr of business with all working days', function(){
moment.locale('us',{
workingWeekdays: [0,1,2,3,4,5,6]
});
var diff = moment('06-18-2017', 'MM-DD-YYYY').businessDiff(moment('05-18-2017'))
expect(diff).to.eql(31)
});
it('Should be zero days if start and end is same', function(){

@@ -187,0 +198,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc