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

sla_work_time

v0.0.5

Published

<h2 align='center'> SLA work time [0.0.4] </h2>

Downloads

156

Readme


View demo

Installation

npm i sla_work_time

or

yarn add sla_work_time

Usage

import { setSkipDays, addMinutes, configure, utils } from 'sla_work_time';

configure({
  // Setting work hours as 8:30AM to 5:30PM
  startAM: 8.5,
  endPM: 17.5,
});

setSkipDays([
  // Add DISTINCT holidays/days to exclude in { startDate, endDate (optional) } format.
  {
    startDate: '2022-11-25',
  },
  {
    startDate: '2022-11-29',
    endDate: '2022-11-30',
  },
  {
    startDate: '2022-12-02',
    endDate: '2022-12-12',
  },
]);

// Supports Date[] format (does internal duplicate removal->sorting->parsing this way)
// setSkipDays(['2022-12-01', '2022-12-02', '2022-12-03', '2022-12-05'])

const newDate = addMinutes('2022-11-28T16:18:44', 3600);

console.log(utils.formatDate(newDate, 'YYYY-MM-DDTHH:mm:ss')); // 2022-12-19T13:18:00

! NOTE !

To keep the system's list of holidays up-to-date, the setSkipDays function should be periodically called to update the in-memory list. This can be done either through an ETL job or periodic API calls to inject updated holiday information into the system. The service layer of the system is responsible for handling these updates.

Available methods


| Method | Params | Description | | ------------------------ | ------------------------------------------------------ | ------------------------------------------------------------------- | | addMinutes || addHours | (date, minutes || hours, config: DurationAddOptions) | Adds duration to the date following the config options. | | toNextWorkTime | (date: DateTime, fixTime: Boolean = true) | Gets the given date back to valid work day and hours if it's not | | validateSkipDay | (date: DateTime, fixTime: Boolean = true) | Gets the date out of holiday (if it's in one) | | configure | (config: { startAM, endPM }) | Sets the work hours for any day. | | setSkipDays | (skipDays: [{ startDate, endDate }] || Date[]) | Sets date to exclude from minute additions (For instance, holidays) |


Description

These exposed functions add durations to a date considering work hours, week ends and skip days(holidays). For example, adding 25 minutes to the date Friday 05:55PM would result in Monday 09:20AM for [Mon-Fri] & [9AM - 6PM] work hour settings.

Contributing


Fee free to open a pull request with detailed title and description about the feature.

For reporting any bug/issues make sure to add a detailed bug reproduction process(a sandbox link if possible) in the description.

License

MIT © sawrozpdl