1.0.13 • Published 2 years ago

ibusy v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm version CI/CD

IBusy

logo

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

Installation

<script src="https://cdn.jsdelivr.net/npm/ibusy@latest/dist/ibusy.js"></script>

Or NPM

npm i ibusy

Overview

<script src="https://cdn.jsdelivr.net/npm/ibusy@latest/dist/ibusy.js"></script>
<script>
  const _ibusy = new ibusy.IBusy();
  const periods = _ibusy.getAllowedPeriodsBetween(
    [
      {
        start: new Date("2021-12-29T01:00:00.000Z").getTime(),
        end: new Date("2021-12-29T22:00:00.000Z").getTime(),
      },
    ],
    [
      {
        start: new Date("2021-12-29T02:00:00.000Z").getTime(),
        end: new Date("2021-12-29T21:00:00.000Z").getTime(),
      },
    ]
  );
</script>

Get the free or available periods by calling getAllowedPeriodsBetween of the global object ibusy and first argument will be the allowed periods. and second argument will be the disallowed periods.

Just simple 😉.

API

getAllowedPeriodsBetween(allowedPeriods, disallowedPeriods);

Pass your allowed and disallowed periods as arguments then IBusy will return the allowed periods after remove the disallowed periods sorted and filtered and detailed so you can use after that.

  • Arguments:
NameTypeRequiredDescription
allowedPeriodsArray<InputPeriod>truearray of type InputPeriod for the available or allowed periods
disallowedPeriodsArray<InputPeriod>truearray of type InputPeriod for the unavailable or disallowed periods
  • Returns:
TypeDescription
Array<InputPeriod>array of type InputPeriod for the available or allowed periods between the two inputs allowed and disallowed periods

Types

  • InputPeriod
NameTypeRequiredExampleDescription
startnumbertrue1640739600000The date as milliseconds
endnumbertrue1640743200000The date as milliseconds
  • Period
NameTypeRequiredExampleDescription
startnumbertrue1640739600000The date as milliseconds
endnumbertrue1640743200000The date as milliseconds
durationnumbertrue480The difference between end and start date into milliseconds
  • Dependencies: | Name | Version | | ------ | ------- | | moment | 2.29.1 |

  • Dev | Name | Version | | ---------- | ------- | | typescript | 4.5.4 | | jest | 27.0.3 |

Contribution

I welcome you to fork and add more features into it. If you have any bugs or feature request, please create an issue at github repository.

1.0.11

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.10

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago