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

@krishnapawar/date-time-slots

v1.0.0

Published

date-time-slots (timeSlot) is a user-friendly JavaScript library for Node.js that simplifies the handling of time slots in projects. It provides easy-to-use methods to convert, manipulate, and generate time slots. Here's a quick rundown:

Downloads

18

Readme

date-time-slots (timeSlot) Library Overview:

date-time-slots (timeSlot) is a user-friendly JavaScript library for Node.js that simplifies the handling of time slots in projects. It provides easy-to-use methods to convert, manipulate, and generate time slots. Here's a quick rundown: This library aims to make working with time slots in Node.js projects straightforward and efficient. Developers can easily integrate it into their applications for effective time management.

install package

npm i date-time-slots
npm i @krishnapawar/date-time-slots

1 Time Conversion:

  • railwayToNormalTimeConvert and formatTimeIn24Hour convert railway time to normal time and vice versa.
  • normalToRailwayTimeConvert changes normal time to railway time.
railwayToNormalTimeConvert("13:00");
formatTimeIn24Hour("13:00");
normalToRailwayTimeConvert("01:00 AM");

Examples.

railwayToNormalTimeConvert method covert railway time into normal time example


    railwayToNormalTimeConvert("13:00");

we can also use same as formatTimeIn24Hour method covert railway time into normal time example


    formatTimeIn24Hour("13:00");

also apposite method same as normalToRalwayTimeConvert method covert normal time into railway time example


    normalToRalwayTimeConvert("01:00 AM");

2 Generating Time Slots:

  • timeSlot generates an array of time slots based on provided start and end times. You can customize the duration and format of the slots.
let slots = timeSlot({ starting_time: '12:00', ending_time: '17:00', duration: 15 });
  • Additional options include handling current time, specific dates, and blocking slots.
let slots = timeSlot({ isCurrent: true, date: "2023-11-05", starting_time: '12:00', ending_time: '17:00' });

timeSlot method covert into simple time slot it take three argument in json starting_time,ending_time,and duration, and it give output in array example ['12:00','12:15','12:30','12:45','01:00','01:15'] example paylode { duration:15, date: "2023-11-05"T10:13:02.481Z, isCurrent: true, starting_time: '12:00', ending_time: '17:00' }


    let data = timeSlot({starting_time: '12:00', ending_time: '17:00' } );

we can pass time as 12 hour format or 24 format is this method it give as same output.


    let data = timeSlot({starting_time: '11:00 PM', ending_time: '01:00 AM' } );

If we want check time with current time and show only remening slot only. then we have to use keyword (isCurrent:true) in this object.


    let data = timeSlot({ isCurrent: true,  starting_time: '12:00', ending_time: '17:00' } );

If we want check time with current time and current date then we have to pass date as well in the object with { date:"2023-10-04", isCurrent:true } and it show only remening slot only in current.


    let data = timeSlot({ date: "2023-11-05", isCurrent: true,  starting_time: '12:00', ending_time: '17:00' } );

By default It make 15 minuts time slot If you want to change time slot duration you can chang using keyword => duration:30,


    let data = timeSlot({ duration: 15, date: "2023-11-05", isCurrent: true,  starting_time: '12:00', ending_time: '17:00' } );

If you want show slot current time to next slot then use keyword next:true.


    let data = timeSlot({ 
        duration: 15, 
        date: "2023-11-05", 
        isCurrent: true,  
        starting_time: '12:00', 
        ending_time: '17:00', 
        next:true 
        } );

if you want slot in 24 hour time you can use keyword =>isNotRailwayTime:true, It give you time slot in 24 hour time.


    let data = timeSlot({ 
        duration: 15, 
        date: "2023-11-05", 
        isCurrent: true,  
        starting_time: '12:00', 
        ending_time: '17:00', 
        next:true,
        isNotRailwayTime:true, 
        } );

If you want to block time slot with pertitucler date we have to use => blockSchedule:[ // "12:15 PM", // "12:30 PM", // "12:45 PM", "12:00", "14:00", ] with array object with block slot and date with keyword =>date:"2023-10-04". exmaple


    let data = timeSlot({ 
        duration: 15, 
        date: "2023-11-05", 
        isCurrent: true,  
        starting_time: '12:00', 
        ending_time: '17:00', 
        next:true,
        isNotRailwayTime:true,
        blockSchedule:[
            // "12:15 PM",
            // "12:30 PM",
            // "12:45 PM",
            "12:00",
            "14:00",
        ]  
        } );

3 Pair of Time Slots:

  • startToEndTimeSlot generates pairs of start and end times based on given parameters. Similar customization options are available.
let timePairs = startToEndTimeSlot("11:00 PM", "01:00 AM", { isCurrent: true, date: "2023-10-04" });
  • startToEndTimeSlot method covert into pair of time slot in object format. it take three argument in startToEndTimeSlot() method, starting_time,ending_time, and object, and object is optional. we can pass time as 12 hour format or 24 format is this method it give as same output. exmaple given below.

12 hour format


let data =startToEndTimeSlot("11:00 PM","01:00 AM");

24 hour format


let data =startToEndTimeSlot("11:00","'17:00'");
  • If we want check time with current time and show only remening slot only. then we have to use keyword (isCurrent:true) in this object.

let data =startToEndTimeSlot("11:00 PM","01:00 AM",{
    isCurrent:true
});
  • If we want check time with current time and current date then we have to pass date as well in the object with { date:"2023-10-04", isCurrent:true } and it show only remening slot only in current.

let data =startToEndTimeSlot("11:00 PM","01:00 AM",{
    date:"2023-10-04",
    isCurrent:true
});
  • If you want to block time slot with pertitucler date we have to use =>blockSchedule:[{"slot": "9:15 PM - 9:30 PM"}] with array object with block slot and date with keyword =>date:"2023-10-04". exmaple

let data =startToEndTimeSlot("11:00 PM","01:00 AM",{
        blockSchedule:[
                {
                    "slot": "9:15 PM - 9:30 PM"
                },
                {
                    "slot": "9:45 PM - 10:00 PM"
                }
            ],
        date:"2023-10-04",
        isCurrent:true
    });
  • By default It make 15 minuts time slot If you want to change time slot duration you can chang using keyword => duration:30,

let data =startToEndTimeSlot("11:00 PM","01:00 AM",{
        blockSchedule:[
                {
                    "slot": "9:15 PM - 9:30 PM"
                },
                {
                    "slot": "9:45 PM - 10:00 PM"
                }
            ],
        date:"2023-10-04",
        isCurrent:true,
        duration:30,
    });
  • if you want slot in 24 hour time you can use keyword =>isNotRailwayTime:true, It give you time slot in 24 hour time.

let data =startToEndTimeSlot("11:00 PM","01:00 AM",{
        blockSchedule:[
                {
                    "slot": "9:15 PM - 9:30 PM"
                },
                {
                    "slot": "9:45 PM - 10:00 PM"
                }
            ],
        date:"2023-10-04",
        isCurrent:true,
        duration:30,
        isNotRailwayTime:true,
    });
  • If you want date with slot you can use key word =>withDate:true,

let data =startToEndTimeSlot("11:00 PM","01:00 AM",{
        blockSchedule:[
                {
                    "slot": "9:15 PM - 9:30 PM"
                },
                {
                    "slot": "9:45 PM - 10:00 PM"
                }
            ],
        date:"2023-10-04",
        isCurrent:true,
        withDate:true,
        duration:30,
        isNotRailwayTime:true,
    });
  • If we want response in start,end in form of keys and values object. then we have to use keyword =>startToEndObj:true,

let data =startToEndTimeSlot("11:00 PM","01:00 AM",{
        blockSchedule:[
                {
                    "start": "10:45",
                    "end": "11:00",
                    "date": "2023-11-13"
                },
                {
                    "start": "11:00",
                    "end": "11:15",
                    "date": "2023-11-13"
                }
            ],
        date:"2023-11-13",
        isCurrent:true,
        withDate:true,
        duration:30,
        isNotRailwayTime:true,
        startToEndObj:true,
    });