]> source.dussan.org Git - gitblit.git/commitdiff
Fixed build script. Fixed date display on activity page headers.
authorJames Moger <james.moger@gitblit.com>
Sun, 20 Nov 2011 20:07:04 +0000 (15:07 -0500)
committerJames Moger <james.moger@gitblit.com>
Sun, 20 Nov 2011 20:07:04 +0000 (15:07 -0500)
build.xml
src/com/gitblit/utils/TimeUtils.java
src/com/gitblit/wicket/WicketUtils.java
tests/com/gitblit/tests/TimeUtilsTest.java

index fc2324a37e7bdca1e055fb0ec959fb1a166e396a..4d5ce6ec900ffad4fbf3695f90852815d1b52586 100644 (file)
--- a/build.xml
+++ b/build.xml
        <target name="buildManager" depends="compile" description="Builds the stand-alone Gitblit Manager">\r
                <echo>Building Gitblit Manager ${gb.version}</echo>\r
        \r
-               <genjar jarfile="maanager-${gb.version}.jar">\r
+               <genjar jarfile="manager-${gb.version}.jar">\r
                        <resource file="${basedir}/src/com/gitblit/client/splash.png" />\r
                        <resource file="${basedir}/resources/gitblt-favicon.png" />\r
                        <resource file="${basedir}/resources/gitweb-favicon.png" />\r
index ef8d428709b689154d79931298d4e2d2dbe9342a..6cc4dcb5390eab61e4ee2d72b888bb789135f9e5 100644 (file)
@@ -145,15 +145,13 @@ public class TimeUtils {
         * Return the difference in days between now and the date.\r
         * \r
         * @param date\r
-        * @param roundup\r
         * @return days ago\r
         */\r
-       public static int daysAgo(Date date, boolean roundup) {\r
-               long diff = System.currentTimeMillis() - date.getTime();\r
+       public static int daysAgo(Date date) {\r
+               long today = ONEDAY * (System.currentTimeMillis()/ONEDAY);\r
+               long day = ONEDAY * (date.getTime()/ONEDAY);\r
+               long diff = today - day;\r
                int days = (int) (diff / ONEDAY);\r
-               if (roundup && (diff % ONEDAY) > 0) {\r
-                       days++;\r
-               }\r
                return days;\r
        }\r
 \r
@@ -208,7 +206,7 @@ public class TimeUtils {
                        if (css) {\r
                                return "age2";\r
                        }\r
-                       int days = daysAgo(date, true);\r
+                       int days = daysAgo(date);\r
                        if (days < 365) {\r
                                if (days <= 30) {\r
                                        return days + " days ago";\r
index 0a207189e5ede18ebdd73097ed2cfab2dc042b28..e8c5e1544598e654b02453c8ca48bd562d561b46 100644 (file)
@@ -453,7 +453,11 @@ public class WicketUtils {
                        dateString = df.format(date);\r
                }\r
                String title = null;\r
-               if (date.getTime() <= System.currentTimeMillis()) {\r
+               if (TimeUtils.isToday(date)) {\r
+                       title = "today";\r
+               } else if (TimeUtils.isYesterday(date)) {\r
+                               title = "yesterday";\r
+               } else if (date.getTime() <= System.currentTimeMillis()) {\r
                        // past\r
                        title = TimeUtils.timeAgo(date);\r
                }\r
index 07ed827c5fcafd8c0110f9b9f54d538827e6837e..530e53c947071fd8155ee0ed91cf9525122ebe68 100644 (file)
@@ -28,14 +28,13 @@ public class TimeUtilsTest extends TestCase {
        }\r
 \r
        public void testBasicTimeFunctions() throws Exception {\r
-               assertTrue(TimeUtils.minutesAgo(offset(2 * TimeUtils.MIN), false) == 2);\r
-               assertTrue(TimeUtils.minutesAgo(offset((2 * TimeUtils.MIN) + (35 * 1000L)), true) == 3);\r
+               assertEquals(2, TimeUtils.minutesAgo(offset(2 * TimeUtils.MIN), false));\r
+               assertEquals(3, TimeUtils.minutesAgo(offset((2 * TimeUtils.MIN) + (35 * 1000L)), true));\r
 \r
-               assertTrue(TimeUtils.hoursAgo(offset(2 * TimeUtils.ONEHOUR), false) == 2);\r
-               assertTrue(TimeUtils.hoursAgo(offset(5 * TimeUtils.HALFHOUR), true) == 3);\r
+               assertEquals(2, TimeUtils.hoursAgo(offset(2 * TimeUtils.ONEHOUR), false));\r
+               assertEquals(3, TimeUtils.hoursAgo(offset(5 * TimeUtils.HALFHOUR), true));\r
 \r
-               assertTrue(TimeUtils.daysAgo(offset(4 * TimeUtils.ONEDAY), false) == 4);\r
-               assertTrue(TimeUtils.daysAgo(offset(4 * TimeUtils.ONEDAY + 12 * TimeUtils.ONEHOUR), true) == 5);\r
+               assertEquals(4, TimeUtils.daysAgo(offset(4 * TimeUtils.ONEDAY)));\r
        }\r
 \r
        public void testToday() throws Exception {\r