Coder Social home page Coder Social logo

jamiemason / is-office-hours Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 336 KB

Determine whether a given date is within office hours

Home Page: https://www.npmjs.com/package/is-office-hours

License: MIT License

JavaScript 6.60% TypeScript 93.40%
date-time datetime dates times office-hours business-time business-hours working-day working-hours

is-office-hours's Introduction

is-office-hours

Determine whether a given date is within office hours

NPM version NPM downloads Build Status Maintainability

Table of Contents

๐ŸŒฉ Installation

npm install --save is-office-hours

๐Ÿ•น Usage

isOfficeHours

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

outsideOfficeHours

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)

๐Ÿ™‹๐Ÿฝโ€โ™€๏ธ Getting Help

Get help with issues by creating a Bug Report or discuss ideas by opening a Feature Request.

๐Ÿ‘€ Other Projects

If you find my Open Source projects useful, please share them โค๏ธ

๐Ÿค“ Author

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.

Follow JamieMason on GitHubย ย ย ย ย ย Follow fold_left on Twitter

is-office-hours's People

Contributors

jamiemason avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.