npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dutyhours

v1.0.2

Published

A tool to calculate total working hours in a given month, taking into account public holidays and configurable working days.

Downloads

249

Readme

🕒 DutyHours

A flexible tool for calculating the total number of working hours in a given month, considering public holidays and customizable working days. This library allows you to specify which days of the week should be considered as working days and accounts for holidays.

🚀 Features

  • Customizable working days – Choose which days of the week should be considered working days.
  • Flexible working hours – Set the number of working hours per day.
  • Holiday handling – Include public holidays from your country.
  • Configurable month and year – Specify the month and year for which you want to calculate working hours.

🛠️ Installation

npm install dutyhours

📖 Usage

JavaScript/TypeScript

import calculateWorkingHours from 'dutyhours';

// Basic usage
const workingHours = calculateWorkingHours({ country: 'PL' });
console.log(`Total working hours: ${workingHours}`);

// More custom usage
const customWorkingHours = calculateWorkingHours({
  country: 'PL',
  hoursPerDay: 6,
  withSaturdays: true,
  withoutThursdays: true,
  month: 5, // May
  year: 2024
});
console.log(`Total working hours: ${customWorkingHours}`);

Command Line Interface (CLI)

You can also use it via the command line:

# Calculate working hours for PL in the current month
npx dutyhours PL

# More custom calculations...
npx dutyhours PL --month 5 --year 2024
npx dutyhours PL --withSaturdays --hours 6
npx dutyhours PL --withoutFridays

🔧 API

calculateWorkingHours(options: Options): number

Calculates the total number of working hours in the given month, considering public holidays and configurable working days.

  • options (object):
    • country (string): The country code to determine the public holidays. In ISO 3166-1 alpha-2 format. For example, 'US' for United States, 'PL' for Poland, etc.
    • hoursPerDay (number, optional): The number of working hours per day. Defaults to 8.
    • withMondays, withTuesdays, withWednesdays, withThursdays, withFridays, withSaturdays, withSundays (boolean, optional): Whether to include these days as working days. Defaults to true for weekdays, false for weekends.
    • withoutMondays, withoutTuesdays, withoutWednesdays, withoutThursdays, withoutFridays, withoutSaturdays, withoutSundays (boolean, optional): Whether to exclude these days from working days.
    • month (number, optional): The month to calculate working hours for (1 to 12). Defaults to the current month.
    • year (number, optional): The year to calculate working hours for. Defaults to the current year.