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
1
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 0.0.7 to 0.0.8

tests/test.js

26

index.js
'use strict';
var moment = require('moment');
moment.fn.isHoliday = function () {
var locale = this.localeData();
if (locale._holidays) {
if (locale._holidays.indexOf(this.format(locale._holidayFormat)) >= 0) return true;
}
return false;
};
moment.fn.isBusinessDay = function() {
return !(this.day() === 0 || this.day() === 6);
if (this.day() === 0 || this.day() === 6) return false;
if (this.isHoliday()) return false;
return true;
};

@@ -67,2 +79,14 @@

moment.fn.prevBusinessDay = function() {
var loop = 1;
var limit = 7;
while (loop < limit) {
if (this.subtract(1, 'd').isBusinessDay()) {
break;
};
loop++;
};
return this;
};
moment.fn.monthBusinessDays = function() {

@@ -69,0 +93,0 @@ var me = this.clone();

11

package.json
{
"name": "moment-business-days",
"version": "0.0.7",
"version": "0.0.8",
"description": "MomentJS pluin to use business days ",
"main": "index.js",
"scripts": {
"test": "./test.js"
"test": "node ./test.js",
"mochatest": "mocha tests/*"
},

@@ -29,3 +30,7 @@ "repository": {

},
"homepage": "https://github.com/kalmecak/moment-business-days"
"homepage": "https://github.com/kalmecak/moment-business-days",
"devDependencies": {
"chai": "^3.3.0",
"mocha": "^2.3.3"
}
}

@@ -14,4 +14,26 @@ # moment-business-days

// You'll be able use moment as you normally do
````
#### Use localizaton to configure holidays:
````javascript
var moment = require('moment-business-days');
var july4th = '07-04-2015';
var laborDay = '09-07-2015';
moment.locale('us', {
holidays: [july4th, laborDay],
holidayFormat: 'MM-DD-YYYY'
});
// moment-business-days will now stop considering these holidays as business days
````
#### Run Tests:
`npm test`
### Methods:

@@ -61,2 +83,14 @@

**prevBusinessDay()**
Will retrieve the previous business date as moment date object:
```javascript
//Previous busines day of Monday 02-02-2015
moment('02-02-2015', 'DD-MM-YYYY').prevBusinessDay()._d // Fri Jan 30 2015 00:00:00 GMT-0600 (CST)
//Previous busines day of Tuesday 03-02-2015
moment('03-02-2015', 'DD-MM-YYYY').prevBusinessDay()._d //Mon Feb 02 2015 00:00:00 GMT-0600 (CST)
```
**monthBusinessDays()**

@@ -63,0 +97,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