Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

business-timer

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

business-timer

Calculate time during working hours

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Business Timer

Lightweight utilities for calculating time during business hours.

Installation

$ npm i business-timer

Usage

Create an instance of BusinessTimer and put it to work:

import BusinessTimer from 'business-timer';

const bt = new BusinessTimer(opts);
const dt = bt.diff('2020-01-01T00:00:00Z', '2020-01-10T00:00:00Z');
console.log(dt); // 291600000

Options

A new BusinessTimer can be configured with both weekly and holiday schedules:

const opts = {
  hours: [ // Sun, Mon, ...
    null,
    ["08:00", "17:00"],
    ["08:00", "17:00"],
    ["08:00", "17:00"],
    ["08:00", "17:00"],
    ["08:00", "17:00"],
    null,
  ],
  holidays: [
    '2021-04-01'
  ],
  timeZone: 'America/Los_Angeles',
};

const bt = new BusinessTimer(opts);

diff(begin: DateLike, end: DateLike): number

Computes the working time elapsed (in ms) between begin and end.

isOpen(datetime: DateLike): boolean

Check whether datetime falls within business hours

isWorkday(date: DateLike): boolean

Check whether date is a workday for the business

License

ISC

FAQs

Package last updated on 06 Feb 2021

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

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