From be0fb213529d9d571078c59e534dbbd6b6cfc46c Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Tue, 28 Jun 2011 22:12:35 -0400
Subject: [PATCH] Use Sitename on login page.
---
src/com/gitblit/utils/TimeUtils.java | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/com/gitblit/utils/TimeUtils.java b/src/com/gitblit/utils/TimeUtils.java
index 805b44f..dcb60ab 100644
--- a/src/com/gitblit/utils/TimeUtils.java
+++ b/src/com/gitblit/utils/TimeUtils.java
@@ -15,6 +15,7 @@
*/
package com.gitblit.utils;
+import java.util.Calendar;
import java.util.Date;
public class TimeUtils {
@@ -28,18 +29,15 @@
public static final long ONEYEAR = ONEDAY * 365L;
- @SuppressWarnings("deprecation")
public static boolean isToday(Date date) {
- Date now = new Date();
- return now.getDate() == date.getDate() && now.getMonth() == date.getMonth()
- && now.getYear() == date.getYear();
+ return (System.currentTimeMillis() - date.getTime()) < ONEDAY;
}
- @SuppressWarnings("deprecation")
public static boolean isYesterday(Date date) {
- Date now = new Date();
- return now.getDate() == (date.getDate() + 1) && now.getMonth() == date.getMonth()
- && now.getYear() == date.getYear();
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ cal.add(Calendar.DATE, 1);
+ return (System.currentTimeMillis() - cal.getTimeInMillis()) < ONEDAY;
}
public static String duration(int days) {
@@ -47,7 +45,7 @@
return days + (days > 1 ? " days" : " day");
} else if (days < 365) {
int rem = days % 30;
- return (days / 30) + (rem >= 15 ? 1 : 0) + " months";
+ return ((days / 30) + (rem >= 15 ? 1 : 0)) + " months";
} else {
int years = days / 365;
int rem = days % 365;
--
Gitblit v1.9.1