Rewrite timer command to use JSON
* Rewrite parseTime to use seconds instead of ms * Move parseTime to timer subdirectory * Implement checkTimer and sendTimerReminder.
This commit is contained in:
parent
a4b75b0161
commit
04f39582a4
7 changed files with 55 additions and 14 deletions
19
util/timer/parseTime.js
Normal file
19
util/timer/parseTime.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
module.exports = function(time){
|
||||
let timeInSeconds = parseInt(time.slice(0, time.length - 1))
|
||||
let letter = time.slice(time.length - 1)
|
||||
if(!isNaN(letter)) return parseInt(time) * 60;
|
||||
switch (letter.toUpperCase()) {
|
||||
case "H":
|
||||
timeInSeconds = timeInSeconds * 3600; // 3 600 000
|
||||
break;
|
||||
case "M":
|
||||
timeInSeconds = timeInSeconds * 60; // 60 000
|
||||
break;
|
||||
case "S":
|
||||
timeInSeconds = timeInSeconds; // 1 000
|
||||
break;
|
||||
default:
|
||||
timeInSeconds = -1;
|
||||
}
|
||||
return timeInSeconds;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue