From d3a20e7a01969a0d499188e3011fd80f4b50a217 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Wed, 20 Apr 2016 15:11:35 +0200 Subject: [PATCH] Bugfix: miscalculated volume expired label Fixes miscalculation when to set volume expired label. --- public/js/dataTables.functions.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/js/dataTables.functions.js b/public/js/dataTables.functions.js index 071930fc76b..53ee394ce63 100644 --- a/public/js/dataTables.functions.js +++ b/public/js/dataTables.functions.js @@ -120,18 +120,22 @@ function formatExpiration(volstatus, lastwritten, volretention) { var b = new Date(a[0]).getTime() / 1000; var interval = (d - b) / (3600 * 24); var retention = Math.round(volretention / 60 / 60 / 24); - var expiration = Math.round(retention - interval); + var expiration = (retention - interval).toFixed(2); if(expiration <= 0) { return 'expired'; } - if(expiration > 0) { - return 'expires in ' + expiration + ' day(s)'; + if(expiration > 0 && expiration <= 1) { + return 'expires in 1 day'; + } + + if(expiration > 1) { + return 'expires in ' + Math.ceil(expiration) + ' days'; } } } else { - return Math.round((volretention / 60 / 60 / 24)) + ' day(s)'; + return Math.ceil((volretention / 60 / 60 / 24)) + ' day(s)'; } }