Socket
Socket
Sign inDemoInstall

moment-holiday

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1-beta.1 to 0.0.1-beta.2

.travis.yml

5

CHANGELOG.md

@@ -0,1 +1,6 @@

### [0.0.1-beta.2](https://github.com/darrinholst/moment-holiday/releases/tag/0.0.1-beta.1)
* API changes to better reflect what the current holiday counter is doing.
* Require explicit use of a holiday config. i.e. `new US()`
### [0.0.1-beta.1](https://github.com/darrinholst/moment-holiday/releases/tag/0.0.1-beta.1)

@@ -2,0 +7,0 @@

9

dist/holidays.d.ts
import * as moment from 'moment';
export declare enum HolidaySet {
UsMinimal = "US_MINIMAL",
export declare abstract class Holidays {
abstract countBusinessHolidaysBetween(fromDate: moment.Moment | string, toDate: moment.Moment | string): number;
protected observedHoliday(date: string): moment.Moment;
protected third(year: number, month: string, day: string): moment.Moment;
protected last(year: number, month: string, day: string): moment.Moment;
protected first(year: number, month: string, day: string): moment.Moment;
}
export declare function holidays(whichOnes: HolidaySet, startDate: moment.Moment | string, endDate: moment.Moment | string): number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var moment = require("moment");
var us_minimal_1 = require("./sets/us-minimal");
var HolidaySet;
(function (HolidaySet) {
HolidaySet["UsMinimal"] = "US_MINIMAL";
})(HolidaySet = exports.HolidaySet || (exports.HolidaySet = {}));
;
var sets = (_a = {},
_a[HolidaySet.UsMinimal] = new us_minimal_1.UsMinimal(),
_a);
function holidays(whichOnes, startDate, endDate) {
var holidaySet = sets[whichOnes];
if (!holidaySet)
throw new Error("No holiday config found for " + whichOnes);
return holidaySet.count(moment(startDate), moment(endDate));
}
exports.holidays = holidays;
var _a;
var Holidays = (function () {
function Holidays() {
}
Holidays.prototype.observedHoliday = function (date) {
var momentized = moment(date);
if (momentized.day() === 0)
return momentized.add(1, 'day');
if (momentized.day() === 6)
return momentized.subtract(1, 'day');
return momentized;
};
Holidays.prototype.third = function (year, month, day) {
return this.first(year, month, 'Thursday').add(3, 'weeks');
};
Holidays.prototype.last = function (year, month, day) {
return moment(year + "-" + month + "-01").endOf('month').startOf('isoWeek');
};
Holidays.prototype.first = function (year, month, day) {
var theFirstDayOfTheMonth = moment(year + "-" + month + "-01")
.startOf('month')
.day(day);
if (theFirstDayOfTheMonth.date() > 7)
theFirstDayOfTheMonth.add(7, 'days');
return theFirstDayOfTheMonth;
};
return Holidays;
}());
exports.Holidays = Holidays;
//# sourceMappingURL=holidays.js.map

@@ -1,1 +0,1 @@

export * from './holidays';
export * from './us';

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./holidays"));
__export(require("./us"));
//# sourceMappingURL=index.js.map
{
"name": "moment-holiday",
"version": "0.0.1-beta.1",
"version": "0.0.1-beta.2",
"description": "Methods to work with holidays in moment.",

@@ -8,6 +8,7 @@ "main": "dist/index.js",

"scripts": {
"lint": "tslint **/*.ts",
"pretest": "npm run compile",
"test": "mocha -c **/*.spec.js",
"compile": "rimraf dist && tsc",
"prepublish": "npm run compile"
"prepublish": "npm run lint && npm run test"
},

@@ -22,3 +23,4 @@ "repository": {

"moment.js",
"holiday"
"holiday",
"holidays"
],

@@ -37,4 +39,6 @@ "author": "Darrin Holst <darrinholst@gmail.com>",

"moment": "^2.18.1",
"prettier": "^1.5.3",
"release-it": "^2.8.0",
"rimraf": "^2.6.1",
"tslint": "^5.5.0",
"typescript": "^2.4.1"

@@ -41,0 +45,0 @@ },

# moment-holiday
Holiday utilities for Moment. API is up for debate. I'm not totally in love with it so PRs are
welcomed.
[![npm-version](https://img.shields.io/npm/v/moment-holiday.svg)](https://www.npmjs.com/package/moment-holiday)
[![Build Status](https://travis-ci.org/darrinholst/moment-holiday.svg?branch=master)](https://travis-ci.org/darrinholst/moment-holiday)
[![dependencies](https://david-dm.org/darrinholst/moment-holiday/status.svg)](https://david-dm.org/darrinholst/moment-holiday)
[![dev dependencies](https://david-dm.org/darrinholst/moment-holiday/dev-status.svg)](https://david-dm.org/darrinholst/moment-holiday?type=dev)
[![peer dependencies](https://david-dm.org/darrinholst/moment-holiday/peer-status.svg)](https://david-dm.org/darrinholst/moment-holiday?type=peer)
Holiday utilities for Moment.
### API
##### `holidays(holidaySet, startDate, endDate)`
##### `countBusinessHolidaysBetween(startDate: Moment | string, endDate: Moment | string)`
Counts the number of holidays between `startDate` and `endDate` as defined by the rules of
`holidaySet`
Returns the number of holidays observed by businesses between `startDate` and `endDate`.
``` js
let {HolidaySet, holidays} = require('moment-holiday');
import {US} from 'moment-holiday';
holidays(HolidaySet.UsMinimal, '2017-01-01', '2017-12-31'); // => 6
new US().countBusinessHolidaysBetween('2017-01-01', '2017-12-31'); // => 6
```
### Holiday Sets
### Holiday Rules
All the rules for determining holidays is encapsulated in a `HolidaySet`. The only one currently
implemented is `UsMinimal` which recognizes:
All the rules for determining holidays is encapsulated in a `Holidays` object. `US` is currently the
only one that's builtin. It recognizes:

@@ -24,0 +28,0 @@ 1. New Years Day

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc