From caaf39a8984b83cf2269be5105a99bef35d83ddf 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/flux-cron b/src/cmd/flux-cron index 35364916b932..bd5548752927 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: @@ -96,10 +96,10 @@ local function reladate (t) -- weeks for past 10 weeks or so, reduce precision in output: local d = math.floor (diff) if (d < 70) then - return fmt ("%d weeks ago", (d + 3) / 7) + return fmt ("%d weeks ago", math.floor ((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)