Support weeks (w) in delays (mutes, reminders, etc.)
This commit is contained in:
parent
5eeb3d2536
commit
838448153b
1 changed files with 3 additions and 2 deletions
|
@ -15,7 +15,7 @@ import tmp from "tmp";
|
|||
* @returns {Number}
|
||||
*/
|
||||
export function convertDelayStringToMS(str) {
|
||||
const regex = /^([0-9]+)\s*([dhms])?[a-z]*\s*/;
|
||||
const regex = /^([0-9]+)\s*([wdhms])?[a-z]*\s*/;
|
||||
let match;
|
||||
let ms = 0;
|
||||
|
||||
|
@ -23,7 +23,8 @@ export function convertDelayStringToMS(str) {
|
|||
|
||||
// tslint:disable-next-line
|
||||
while (str !== "" && (match = str.match(regex)) !== null) {
|
||||
if (match[2] === "d") ms += match[1] * 1000 * 60 * 60 * 24;
|
||||
if (match[2] === "w") ms += match[1] * 1000 * 60 * 60 * 24 * 7;
|
||||
else if (match[2] === "d") ms += match[1] * 1000 * 60 * 60 * 24;
|
||||
else if (match[2] === "h") ms += match[1] * 1000 * 60 * 60;
|
||||
else if (match[2] === "s") ms += match[1] * 1000;
|
||||
else if (match[2] === "m" || !match[2]) ms += match[1] * 1000 * 60;
|
||||
|
|
Loading…
Add table
Reference in a new issue