Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

this-month

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

this-month

Utility library to get details about an specific month.

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

ThisMonth

Version Downloads License

How many natural days does April has? How many business days does February has? How many Holidays are there in December? How many Weeks does June has? How many Sundays in September?

ThisMonth can help you with this details!

ThisMonth is an small utility class that provides useful methods to get calculations and details of an specific month.

Installation

npm install this-month --save or yarn add this-month

Usage

const ThisMonth = require('this-month').default;

// ES6

import ThisMonth from 'this-month';
const february = new ThisMonth({
    year: 2017,
    month: 2
})

const totalDays = february.numberOfNaturalDays(); // 28
const totalBusinessDays = february.numberOfBusinessDays(); // 19 (Using default days off - Sat, Sun)

Initial settings

OptionTypeDescriptionRequired
yearintYear of the monthyes
monthintMonth of the yearyes
daysOffarrayNames of weekly days offNo
holidaysarrayHoliday dates in the yearNo

Example

const december = ThisMonth({
    year: 2017,
    month: 12,
    daysOff: ['Monday'], // working days Tuesday - Sunday,
    holidays: ['2017-12-25', '2017-12-31'] // you can also list all the holiday dates of the year
})
december.numberOfNaturalDays(); // 31
december.numberOfBusinessDays(); // 26 (4 Mondays are off and 2 holidays, but the 25th is Monday so it's already off day)

Methods

MethodDescription
weeklyDaysOffReturns string of day numbers.
numberOfWeeksReturns number of weeks in the month
numberOfNaturalDaysReturns number of days in the month
numberOfDaysOffReturns number of days in the month
numberOfHolidaysReturns number of days in the month
numberOfBusinessDaysReturns number of days in the month
numberOfSundaysReturns number of days in the month
numberOfMondaysReturns number of days in the month
numberOfTuesdaysReturns number of days in the month
numberOfWednesdaysReturns number of days in the month
numberOfThursdaysReturns number of days in the month
numberOfFridaysReturns number of days in the month
numberOfSaturdaysReturns number of days in the month

Keywords

Date

FAQs

Package last updated on 22 Aug 2019

Did you know?

Socket

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.

Install

Related posts