Created
April 7, 2020 19:30
-
-
Save pwketankulkarni/87fa109c8adda9a6e5ba1ac3c718216e to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/jubazut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
console.clear(); | |
let startTime = convertTime('2020-03-02 08:30:00') | |
let endTime = convertTime('2020-03-02 08:35:00'); | |
let arr = [ | |
{"start":"2020-03-01 07:00:00", | |
"end":"2020-03-01 08:30:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
}, | |
{"start":"2020-03-02 07:00:00", | |
"end":"2020-03-02 08:00:00", | |
"title":"Trying to break recurrence", | |
"summary":"1 Station Rod" | |
}, | |
{"start":"2020-03-02 07:00:00", | |
"end":"2020-03-02 08:30:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
}, | |
{"start":"2020-03-03 07:00:00", | |
"end":"2020-03-03 08:40:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
} | |
] | |
function convertTime(inputTime){ | |
return inputTime.split(" ")[1].split(":").map(time=>Number(time)); | |
} | |
function compareTime(requestedslot,oldslot){ | |
let [rh,rm,rs]=requestedslot; | |
let {start,end}=oldslot; | |
let [sh,sm,ss]=start; | |
let [eh,em,es]=end | |
return rh>=sh && rh>eh; | |
} | |
// [9,15,0] | |
// [7,0,0][8,30,0] | |
function display(startTime,endTime){ | |
return arr.every(slot=>compareTime(startTime,{start:convertTime(slot.start),end:convertTime(slot.end)})) | |
} | |
console.log("is available",display(startTime,endTime)) | |
// console.log() | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">console.clear(); | |
let startTime = convertTime('2020-03-02 08:30:00') | |
let endTime = convertTime('2020-03-02 08:35:00'); | |
let arr = [ | |
{"start":"2020-03-01 07:00:00", | |
"end":"2020-03-01 08:30:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
}, | |
{"start":"2020-03-02 07:00:00", | |
"end":"2020-03-02 08:00:00", | |
"title":"Trying to break recurrence", | |
"summary":"1 Station Rod" | |
}, | |
{"start":"2020-03-02 07:00:00", | |
"end":"2020-03-02 08:30:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
}, | |
{"start":"2020-03-03 07:00:00", | |
"end":"2020-03-03 08:40:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
} | |
] | |
function convertTime(inputTime){ | |
return inputTime.split(" ")[1].split(":").map(time=>Number(time)); | |
} | |
function compareTime(requestedslot,oldslot){ | |
let [rh,rm,rs]=requestedslot; | |
let {start,end}=oldslot; | |
let [sh,sm,ss]=start; | |
let [eh,em,es]=end | |
return rh>=sh && rh>eh; | |
} | |
// [9,15,0] | |
// [7,0,0][8,30,0] | |
function display(startTime,endTime){ | |
return arr.every(slot=>compareTime(startTime,{start:convertTime(slot.start),end:convertTime(slot.end)})) | |
} | |
console.log("is available",display(startTime,endTime)) | |
// console.log() | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
let startTime = convertTime('2020-03-02 08:30:00') | |
let endTime = convertTime('2020-03-02 08:35:00'); | |
let arr = [ | |
{"start":"2020-03-01 07:00:00", | |
"end":"2020-03-01 08:30:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
}, | |
{"start":"2020-03-02 07:00:00", | |
"end":"2020-03-02 08:00:00", | |
"title":"Trying to break recurrence", | |
"summary":"1 Station Rod" | |
}, | |
{"start":"2020-03-02 07:00:00", | |
"end":"2020-03-02 08:30:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
}, | |
{"start":"2020-03-03 07:00:00", | |
"end":"2020-03-03 08:40:00", | |
"title":"Chlorinator cell replacement test", | |
"summary":"234 Palmer Street" | |
} | |
] | |
function convertTime(inputTime){ | |
return inputTime.split(" ")[1].split(":").map(time=>Number(time)); | |
} | |
function compareTime(requestedslot,oldslot){ | |
let [rh,rm,rs]=requestedslot; | |
let {start,end}=oldslot; | |
let [sh,sm,ss]=start; | |
let [eh,em,es]=end | |
return rh>=sh && rh>eh; | |
} | |
// [9,15,0] | |
// [7,0,0][8,30,0] | |
function display(startTime,endTime){ | |
return arr.every(slot=>compareTime(startTime,{start:convertTime(slot.start),end:convertTime(slot.end)})) | |
} | |
console.log("is available",display(startTime,endTime)) | |
// console.log() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment