From 8051a29d8b3826772e5be1851eb72cd52ab5080c Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 13 Jan 2012 08:04:06 -0500 Subject: [PATCH] Fixed upgrade bug in user service (issue 41) --- src/com/gitblit/utils/TimeUtils.java | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/com/gitblit/utils/TimeUtils.java b/src/com/gitblit/utils/TimeUtils.java index ef8d428..cd8e895 100644 --- a/src/com/gitblit/utils/TimeUtils.java +++ b/src/com/gitblit/utils/TimeUtils.java @@ -145,15 +145,13 @@ * Return the difference in days between now and the date. * * @param date - * @param roundup * @return days ago */ - public static int daysAgo(Date date, boolean roundup) { - long diff = System.currentTimeMillis() - date.getTime(); + public static int daysAgo(Date date) { + long today = ONEDAY * (System.currentTimeMillis()/ONEDAY); + long day = ONEDAY * (date.getTime()/ONEDAY); + long diff = today - day; int days = (int) (diff / ONEDAY); - if (roundup && (diff % ONEDAY) > 0) { - days++; - } return days; } @@ -208,7 +206,7 @@ if (css) { return "age2"; } - int days = daysAgo(date, true); + int days = daysAgo(date); if (days < 365) { if (days <= 30) { return days + " days ago"; @@ -270,8 +268,6 @@ } else if (frequency.indexOf("hour") > -1) { // convert to minutes mins *= 60; - } else if (frequency.indexOf("min") > -1) { - // default mins } return mins; } -- Gitblit v1.9.1