diff --git a/lib/sandbox.js b/lib/sandbox.js index 45d7e0669..82a8878a2 100644 --- a/lib/sandbox.js +++ b/lib/sandbox.js @@ -3392,6 +3392,8 @@ function sandBox(script, name, verbose, debug, context) { const minute = 60 * second; const hour = 60 * minute; const day = 24 * hour; + const neg = diff < 0; + diff = Math.abs(diff); if (/DD|TT|ДД|D|T|Д/.test(text)) { const days = Math.floor(diff / day); @@ -3439,7 +3441,7 @@ function sandBox(script, name, verbose, debug, context) { sandbox.verbose && sandbox.log(`formatTimeDiff(format=${format}, text=${text})`, 'debug'); - return text; + return neg ? `-${text}` : text; }, getDateObject: function (date) { if (isObject(date)) {