From b8b6e2f497e0d30f4101197e6477a96bc7a5d47d Mon Sep 17 00:00:00 2001 From: paul53 Date: Fri, 10 May 2024 18:26:33 +0200 Subject: [PATCH] Update sandbox.js Berechnung negativer Zeitdifferenzen korrigiert --- lib/sandbox.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)) {