From fbc5de4d24bbd54e9ae44dcb290947b6248a9eb5 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Wed, 13 Oct 2021 11:20:10 -0700 Subject: [PATCH] flux-cron: coerce values to integer when using %d Problem: On centos8 some of the tests in t0016-cron-faketime.t fail with the following error: lua: /usr/src/src/cmd/flux-cron:102: bad argument #2 to 'fmt' (number has no integer representation) Coerce values to integer using math.floor when %d is used in string.format to avoid this error. --- src/cmd/flux-cron | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/flux-cron b/src/cmd/flux-cron index 35364916b932..221009357345 100755 --- a/src/cmd/flux-cron +++ b/src/cmd/flux-cron @@ -78,7 +78,7 @@ local function reladate (t) return fmt ("a minute ago") end if (diff < 90) then - return fmt ("%d minutes ago", diff) + return fmt ("%d minutes ago", math.floor (diff + 0.5)) end -- Convert to hours: @@ -99,7 +99,7 @@ local function reladate (t) return fmt ("%d weeks ago", (d + 3) / 7) end if (d < 365) then - return fmt ("%d months ago", (d + 15) / 30) + return fmt ("%d months ago", math.floor((d + 15) / 30)) end return fmt ("%.1f years ago", diff / 365)