Determine whether a given date is within office hours
npm install --save is-office-hours
Returns true
if the provided Date
falls within Monday to Friday 9:00am to 4:59pm.
import { isOfficeHours } from "is-office-hours";
isOfficeHours(new Date("2019-03-04T08:59:59.000Z"));
// false
isOfficeHours(new Date("2019-03-04T09:00:00.000Z"));
// true
isOfficeHours(new Date("2019-03-04T09:01:00.000Z"));
// true
isOfficeHours(new Date("2019-03-04T16:59:59.000Z"));
// true
isOfficeHours(new Date("2019-03-04T17:00:00.000Z"));
// false
isOfficeHours(new Date("2019-03-04T17:01:00.000Z"));
// false
If the provided date falls within Office Hours, a new date is returned with the time adjusted to fall outside Office Hours. If the provided date falls outside Office Hours, it is returned unchanged.
The provided date is never mutated.
import { outsideOfficeHours } from "is-office-hours";
outsideOfficeHours(new Date("2019-03-04T09:00:00.000Z"));
// Date(2019-03-04T18:00:00.000Z)
outsideOfficeHours(new Date("2019-03-04T10:00:00.000Z"));
// Date(2019-03-04T18:37:29.000Z)
outsideOfficeHours(new Date("2019-03-04T11:00:00.000Z"));
// Date(2019-03-04T19:14:59.000Z)
outsideOfficeHours(new Date("2019-03-04T12:00:00.000Z"));
// Date(2019-03-04T19:52:29.000Z)
outsideOfficeHours(new Date("2019-03-04T13:00:00.000Z"));
// Date(2019-03-04T20:29:59.000Z)
outsideOfficeHours(new Date("2019-03-04T14:00:00.000Z"));
// Date(2019-03-04T21:07:29.000Z)
outsideOfficeHours(new Date("2019-03-04T15:00:00.000Z"));
// Date(2019-03-04T21:44:59.000Z)
outsideOfficeHours(new Date("2019-03-04T16:00:00.000Z"));
// Date(2019-03-04T22:22:29.000Z)
Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.
If you find my Open Source projects useful, please share them ❤️
- eslint-formatter-git-log
ESLint Formatter featuring Git Author, Date, and Hash - eslint-plugin-move-files
Move and rename files while keeping imports up to date - eslint-plugin-prefer-arrow-functions
Convert functions to arrow functions - ImageOptim-CLI
Automates ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of images part of your automated build process. - Jasmine-Matchers
Write Beautiful Specs with Custom Matchers - karma-benchmark
Run Benchmark.js over multiple Browsers, with CI compatible output - self-help
Interactive Q&A Guides for Web and the Command Line - syncpack
Manage multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces
I'm Jamie Mason from Leeds in England, I began Web Design and Development in 1999 and have been Contracting and offering Consultancy as Fold Left Ltd since 2012. Who I've worked with includes Sky Sports, Sky Bet, Sky Poker, The Premier League, William Hill, Shell, Betfair, and Football Clubs including Leeds United, Spurs, West Ham, Arsenal, and more.