-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dacd19f
Showing
7 changed files
with
1,210 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.s[wno]p | ||
node_modules/ | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const parser = require("./parser").parser; | ||
const moment = require("moment"); | ||
|
||
|
||
function generateTimeRanges(timeString, forMoment = moment().startOf("day")) { | ||
return parser.parse(timeString).map(range => { | ||
const start = forMoment.clone(); | ||
start.set("hour", range.start.hour); | ||
start.set("minute", range.start.minute); | ||
|
||
const end = forMoment.clone(); | ||
end.set("hour", range.end.hour); | ||
end.set("minute", range.end.minute); | ||
|
||
return { | ||
start, | ||
end | ||
}; | ||
}); | ||
} | ||
|
||
function inspectTimeString(timeString) { | ||
console.log("========================"); | ||
console.log(`timeString: \n${timeString}`); | ||
console.log(); | ||
const ranges = generateTimeRanges(timeString); | ||
for (const range of ranges) { | ||
console.log(` | ||
From: ${range.start.format("LLL")} | ||
To: ${range.end.format("LLL")} | ||
`); | ||
} | ||
} | ||
|
||
module.exports.generateTimeRanges = generateTimeRanges; | ||
module.exports.inspectTimeString = inspectTimeString; | ||
|
Oops, something went wrong.