{"id":16965177,"url":"https://github.com/essuraj/time-slots-generator","last_synced_at":"2025-08-31T12:12:33.177Z","repository":{"id":146447820,"uuid":"146175733","full_name":"essuraj/time-slots-generator","owner":"essuraj","description":"a time slot generator with ability to filter out blocked times","archived":false,"fork":false,"pushed_at":"2018-09-04T13:57:42.000Z","size":28,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T23:06:03.007Z","etag":null,"topics":["appointment","blocking","time","time-slots"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/essuraj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-26T11:44:27.000Z","updated_at":"2024-10-04T08:19:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"18ee7352-9bb3-4f69-8837-84c33a2ea186","html_url":"https://github.com/essuraj/time-slots-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essuraj%2Ftime-slots-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essuraj%2Ftime-slots-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essuraj%2Ftime-slots-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/essuraj%2Ftime-slots-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/essuraj","download_url":"https://codeload.github.com/essuraj/time-slots-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492871,"owners_count":21113163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appointment","blocking","time","time-slots"],"created_at":"2024-10-13T23:45:14.890Z","updated_at":"2025-04-11T23:06:12.217Z","avatar_url":"https://github.com/essuraj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# time-slots-generator\n[![NPM version](https://img.shields.io/npm/v/time-slots-generator.svg)](https://www.npmjs.com/package/time-slots-generator)\n[![Open Source Love](https://badges.frapsoft.com/os/mit/mit.svg?v=102)](https://github.com/ellerbrock/open-source-badge/)\n### A time slot generator with ability to filter out blocked times.\n\nWritten in ES5 for maximum compatibility.\n\n## Install\n```\nnpm install time-slots-generator --save\n```\n## Usage\n```\nvar ts=require(\"time-slots-generator\");\n\nts.getTimeSlots(blockTimes, showTimeAsString, timeInterval, includeStartBlockedTime, includeEndBlockedTime)\n```\n- blockTimes \n    - `Array of start and end times` \n    - ` default: []`\n    - Use when you want some times periods to be removed(in cases where an appointment is already booked)\n\n    ```\n    // time format\n    // 4:30 ==\u003e 4*60+30 = 270\n    [\n        [270,360], // start and end time\n        [70,1200]\n    ]    \n    ```\n\n- showTimeAsString \n    - `Boolean`\n    - ` default: false`\n    - returns  the output as a map of time and string \n\n     `Eg: {270:'4:30'}`\n\n- timeInterval \n    - `string`\n    - ` default: hour`\n    - splits the time interval based on the string sent, allowed strings are\n    \n     `[\"tenth\",\"quarter\",\"half\",\"one\",\"two\",\"three\",\"four\"]`\n\n- includeStartBlockedTime \n    - `Boolean`\n    - ` default: false`\n    - includes the start times from blockedTimes in the generated array.\n    \n- includeEndBlockedTime \n    - `Boolean`\n    - ` default: false`\n    - includes the end times from blockedTimes in the generated array.\n    \n\n### Full Example\n```javascript\n\nconst tc = require(\"time-slots-generator\");\n\nconsole.log(\"get me all the time slots of the day \\n\",tc.getTimeSlots([],false));\nconsole.log(\"get me all the time slots of the day without the given times \\n\",tc.getTimeSlots([[300,1080]],false));\n\nconsole.log(\"get me all the time slots of the day with time \\n\",tc.getTimeSlots([],true));\nconsole.log(\"get me all the time slots of the day without the given times with time \\n\",tc.getTimeSlots([[300,1080]],true));\n\nconsole.log(\"get me all the time slots of the day with time in 2hr intervals\\n\",tc.getTimeSlots([],true,\"two\"));\nconsole.log(\"get me all the time slots of the day without the given times with time 15min intervals\\n\",tc.getTimeSlots([[300,1080]],true,\"quarter\"));\n\n\n $ node index.js\nget me all the time slots of the day\n [ 60,\n  120,\n  180,\n  240,\n  300,\n  360,\n  420,\n  480,\n  540,\n  600,\n  660,\n  720,\n  780,\n  840,\n  900,\n  960,\n  1020,\n  1080,\n  1140,\n  1200,\n  1260,\n  1320,\n  1380,\n  1440 ]\n\nget me all the time slots of the day without the given times\n [ 60, 120, 180, 240, 1140, 1200, 1260, 1320, 1380, 1440 ]\n\nget me all the time slots of the day with time\n { '60': '1:00',\n  '120': '2:00',\n  '180': '3:00',\n  '240': '4:00',\n  '300': '5:00',\n  '360': '6:00',\n  '420': '7:00',\n  '480': '8:00',\n  '540': '9:00',\n  '600': '10:00',\n  '660': '11:00',\n  '720': '12:00',\n  '780': '13:00',\n  '840': '14:00',\n  '900': '15:00',\n  '960': '16:00',\n  '1020': '17:00',\n  '1080': '18:00',\n  '1140': '19:00',\n  '1200': '20:00',\n  '1260': '21:00',\n  '1320': '22:00',\n  '1380': '23:00',\n  '1440': '24:00' }\n\nget me all the time slots of the day without the given times with time\n { '60': '1:00',\n  '120': '2:00',\n  '180': '3:00',\n  '240': '4:00',\n  '1140': '19:00',\n  '1200': '20:00',\n  '1260': '21:00',\n  '1320': '22:00',\n  '1380': '23:00',\n  '1440': '24:00' }\n\nget me all the time slots of the day with time in 2hr intervals\n { '120': '2:00',\n  '240': '4:00',\n  '360': '6:00',\n  '480': '8:00',\n  '600': '10:00',\n  '720': '12:00',\n  '840': '14:00',\n  '960': '16:00',\n  '1080': '18:00',\n  '1200': '20:00',\n  '1320': '22:00',\n  '1440': '24:00' }\n  \nget me all the time slots of the day without the given times with time 15min intervals\n { '15': '0:15',\n  '30': '0:30',\n  '45': '0:45',\n  '60': '1:00',\n  '75': '1:15',\n  '90': '1:30',\n  '105': '1:45',\n  '120': '2:00',\n  '135': '2:15',\n  '150': '2:30',\n  '165': '2:45',\n  '180': '3:00',\n  '195': '3:15',\n  '210': '3:30',\n  '225': '3:45',\n  '240': '4:00',\n  '255': '4:15',\n  '270': '4:30',\n  '285': '4:45',\n  '1095': '18:15',\n  '1110': '18:30',\n  '1125': '18:45',\n  '1140': '19:00',\n  '1155': '19:15',\n  '1170': '19:30',\n  '1185': '19:45',\n  '1200': '20:00',\n  '1215': '20:15',\n  '1230': '20:30',\n  '1245': '20:45',\n  '1260': '21:00',\n  '1275': '21:15',\n  '1290': '21:30',\n  '1305': '21:45',\n  '1320': '22:00',\n  '1335': '22:15',\n  '1350': '22:30',\n  '1365': '22:45',\n  '1380': '23:00',\n  '1395': '23:15',\n  '1410': '23:30',\n  '1425': '23:45',\n  '1440': '24:00' }\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessuraj%2Ftime-slots-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fessuraj%2Ftime-slots-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessuraj%2Ftime-slots-generator/lists"}