Delete parseTime.js

This commit is contained in:
Jared He 2021-06-14 21:22:53 +00:00
parent 842a425533
commit 1800a22fb4
1 changed files with 0 additions and 20 deletions

View File

@ -1,20 +0,0 @@
const parseTime = (dateStr, timeStr) => {
if (/-/.exec(timeStr)) {
console.error(`${timeStr} has date a range`);
return;
}
timeStr = timeStr.toUpperCase() // converting cases like 7PM to 7PM
if (/[0-9](a|A|p|P)/g.exec(timeStr)) { // converting cases like 7PM to 7 PM
timeStr = timeStr.replace(/[0-9](?=(a|A|p|P))/g, "$& ");
}
if (/(?<!:[0-9])[0-9] (a|A|p|P)/g.exec(timeStr)) { // converting cases like 7 PM to 7:00 PM
timeStr = timeStr.replace(/[0-9](?= )/, "$&:00");
}
let date = new Date(`${dateStr} ${timeStr}`); // convert from CST to EST
date.setHours(date.getHours() + 1);
console.log(date.toString());
return date;
}