Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
slot-calculator
Advanced tools
Calculate time slots for your users to choose from.
Weekly downloads
Readme
Calculate time slots for your users to choose from.
View the JS/TS reference. TypeScript language support in your IDE is sufficient to make use of this package's types and annotations.
Play with a live demo on CodeSandbox
npm install slot-calculator
import { getSlots } from "slot-calculator"
const { allSlots } = getSlots({
from: "2022-01-01",
to: "2022-01-02",
duration: 60,
})
allSlots
: An array of all generated slots. Only use this as a starting point for manipulating the output.availableSlots
: An array of available slots. Only use this as a starting point for manipulating the output.allDates
: An array of dates, including unavailable ones, between the from and to configuration variables. Use this to allow users to specify their own datetime, but within your chosen bounds.availableDates
: An array of available dates. Use this to mark on a calendar which dates can be selected.allSlotsByDay
: Once a user has selected a date, use this object to easily find all the slots for that day.availableSlotsByDay
: Once a user has selected a date, use this object to easily find the available slots for that day.timeTaken
: Worried that the number crunching is slowing down your app? Monitor this variable to see the time taken by slot calculator.For these examples to work, use this setup code:
import { DateTime, Settings } from "luxon";
Settings.defaultZone = "UTC";
const dateTimeRef = DateTime.utc(2022, 1, 1);
getSlots({
from: dateTimeRef.toISO(),
to: dateTimeRef.plus({ hour: 2 }).toISO(),
duration: 60,
});
getSlots({
from: dateTimeRef.toISO(),
to: dateTimeRef.plus({ hour: 3 }).toISO(),
availability: [
{
from: dateTimeRef.plus({ hour: 1 }).toISO(),
to: dateTimeRef.plus({ hour: 2 }).toISO(),
},
],
unavailability: [
{
from: dateTimeRef.plus({ hour: 2 }).toISO(),
to: dateTimeRef.plus({ hour: 3 }).toISO(),
},
],
duration: 60,
});
getSlots({
from: dateTimeRef.toISO(),
to: dateTimeRef.plus({ hour: 2 }).toISO(),
availability: [
{
day: "Saturday",
from: "00:00",
to: "01:00",
metadata: {
user: "Alice",
},
},
{
from: dateTimeRef.plus({ hour: 1 }).toISO(),
to: dateTimeRef.plus({ hour: 2 }).toISO(),
metadata: {
user: "Bob",
},
},
],
duration: 60,
});
getSlots({
from: dateTimeRef.toISO(),
to: dateTimeRef.plus({ hour: 2 }).toISO(),
outputTimezone: "Europe/Paris",
availability: [
{
day: "Saturday",
from: "01:00",
to: "02:00",
timezone: "Europe/Paris",
},
],
duration: 60,
});
FAQs
Calculate time slots for your users to choose from.
The npm package slot-calculator receives a total of 9,619 weekly downloads. As such, slot-calculator popularity was classified as popular.
We found that slot-calculator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.