From a93777e3b70b84cf1ffcb693d3ad28c41bb92065 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 11 May 2024 23:38:26 +0300 Subject: [PATCH] (chore) JSDoc comment --- public/scripts/macros.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/public/scripts/macros.js b/public/scripts/macros.js index 977ee5cf2..aa683c7f1 100644 --- a/public/scripts/macros.js +++ b/public/scripts/macros.js @@ -259,22 +259,23 @@ function diceRollReplace(input, invalidRollPlaceholder = '') { }); } -/* Returns the difference between two times. Works with any time format acceptable by moment(). +/** + * Returns the difference between two times. Works with any time format acceptable by moment(). * Can work with {{date}} {{time}} macros + * @param {string} input - The string to replace time difference macros in. + * @returns {string} The string with replaced time difference macros. */ function timeDiffReplace(input) { const timeDiffPattern = /{{timeDiff::(.*?)::(.*?)}}/gi; - - const output = input.replace(timeDiffPattern, (match, matchPart1, matchPart2) => { - const time1 = new moment(matchPart1); + const output = input.replace(timeDiffPattern, (_match, matchPart1, matchPart2) => { + const time1 = moment(matchPart1); + const time2 = moment(matchPart2); - const time2 = new moment(matchPart2); - const timeDifference = moment.duration(time1.diff(time2)); return timeDifference.humanize(); }); - + return output; }