parent
b22c7058a5
commit
c4a0e60760
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@ |
||||
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; |
||||
} |
Loading…
Reference in new issue