From 4aecba72e71c252beddcd430f7cadbe754d225bf Mon Sep 17 00:00:00 2001 From: RogerSelwyn Date: Wed, 6 May 2020 23:06:34 +0100 Subject: [PATCH] Updated to remove negative diff in time calculation Use of 'def diff = (int) (long)...' causes a negative value when difference is months (23 March to 06 May). No idea why. Changing to 'int diff = ...' removes this problem --- smartapps/tonesto7/nst-automations.src/nst-automations.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smartapps/tonesto7/nst-automations.src/nst-automations.groovy b/smartapps/tonesto7/nst-automations.src/nst-automations.groovy index 01ebd145d..8624bff0a 100644 --- a/smartapps/tonesto7/nst-automations.src/nst-automations.groovy +++ b/smartapps/tonesto7/nst-automations.src/nst-automations.groovy @@ -8338,7 +8338,7 @@ def GetTimeDiffSeconds(strtDate, stpDate=null, methName=null) { */ def start = Date.parse("E MMM dd HH:mm:ss z yyyy", strtDate).getTime() def stop = Date.parse("E MMM dd HH:mm:ss z yyyy", stopVal).getTime() - def diff = (int) (long) (stop - start) / 1000 + int diff = (stop - start) / 1000 LogTrace("[GetTimeDiffSeconds] Results for '$methName': ($diff seconds)") return diff } else { return null }