DEV Community

Mahmoud shahin
Mahmoud shahin

Posted on

IBUSY

Image description

IBusy tool can help you to create and enhance your time management tools and make them better and easier to make them because IBusy has great features that can help you in that.

1 - By IBusy you can get the free period between multiple periods Ex.. likes if you have a person and he is working in specifics times also he has holidays and absences and times he isn't available into so you can get only the times he available into between these periods.

2 - By IBusy you can filter and sort the duplication between multiple periods Ex.. if you have many dates and periods into an array and you need to remove the duplications and nested array and get only the unique periods like that

Demo
Install

npm i ibusy

[
   { start: "2021-12-29T10:00:00.000Z", end: "2021-12-29T15:00:00.000Z" }
   { start: "2021-12-29T14:00:00.000Z", end: "2021-12-29T16:00:00.000Z" }
   { start: "2021-12-29T16:00:00.000Z", end: "2021-12-29T20:00:00.000Z" }
   { start: "2021-12-29T19:00:00.000Z", end: "2021-12-29T23:00:00.000Z" }
   { start: "2021-12-29T21:00:00.000Z", end: "2021-12-29T23:00:00.000Z" }
]
Enter fullscreen mode Exit fullscreen mode

You will get the unique period only

[{ start: "2021-12-29T10:00:00.000Z", end: "2021-12-29T23:00:00.000Z" }];
Tecnology and Dependances:

let's know how we can do that

Just simple to get the free periods.

1 - enter the allowed periods. 2 - ender the disallowed periods. 3 - get the free or available periods by calling getAllowedPeriodsBetween function just simple 😉.

const ibusy = new IBusy();
const periods = ibusy.getAllowedPeriodsBetween(
  [{ start: "2021-12-29T05:00:00.000Z", end: "2021-12-29T22:00:00.000Z" }],
  [
    { start: "2021-12-29T06:00:00.000Z", end: "2021-12-29T12:00:00.000Z" },
    { start: "2021-12-29T13:00:00.000Z", end: "2021-12-29T21:00:00.000Z" }
  ]
);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)