Index: gradle-core/src/test/groovy/org/gradle/util/ClockTest.java
===================================================================
--- gradle-core/src/test/groovy/org/gradle/util/ClockTest.java	Wed Feb 18 23:24:43 EST 2009
+++ gradle-core/src/test/groovy/org/gradle/util/ClockTest.java	Wed Feb 18 23:24:43 EST 2009
@@ -0,0 +1,71 @@
+package org.gradle.util;
+
+import org.jmock.Expectations;
+import org.jmock.integration.junit4.JMock;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(JMock.class)
+public class ClockTest {
+
+    private static final long TEST_BASE_TIME = 641353121231L;
+
+    private JUnit4Mockery context = new JUnit4Mockery();
+    private TimeProvider timeProvider;
+    private Clock clock;
+
+    @Before
+    public void setUp() {
+        timeProvider = context.mock(TimeProvider.class);
+        setBaseTime();
+        clock = new Clock(timeProvider);
+    }
+
+    @Test public void testOnlySecondsTwoDigits() throws Exception {
+        setDtMs(51243);
+        assertEquals("51.243 secs", clock.getTime());
+    }
+
+    @Test public void testOnlySecondsEvenMs() {
+        setDtMs(4000);
+        assertEquals("4.0 secs", clock.getTime());
+    }
+
+    @Test public void testMinutesAndSeconds() {
+        setDtHrsMinsSecsMillis(0, 32, 40, 322);
+        assertEquals("32 mins 40.322 secs", clock.getTime());
+    }
+
+    @Test public void testHoursMinutesAndSeconds() {
+        setDtHrsMinsSecsMillis(3, 2, 5, 111);
+        assertEquals("3 hrs 2 mins 5.111 secs", clock.getTime());
+    }
+
+    @Test public void testHoursZeroMinutes() {
+        setDtHrsMinsSecsMillis(1, 0, 32, 0);
+        assertEquals("1 hrs 0 mins 32.0 secs", clock.getTime());
+    }
+
+    private void setBaseTime() {
+        returnFromTimeProvider(TEST_BASE_TIME);
+    }
+
+    private void setDtMs(final long deltaT) {
+        returnFromTimeProvider(TEST_BASE_TIME + deltaT);
+    }
+
+    private void setDtHrsMinsSecsMillis(int hours, int minutes, int seconds, int millis) {
+        long dt = (hours * 3600 * 1000) + (minutes * 60 * 1000) + (seconds * 1000) + millis;
+        returnFromTimeProvider(TEST_BASE_TIME + dt);
+    }
+
+    private void returnFromTimeProvider(final long time) {
+        context.checking(new Expectations(){{
+            one(timeProvider).getCurrentTime();
+            will(returnValue(time));
+        }});
+    }
+}
Index: gradle-core/src/main/groovy/org/gradle/util/TimeProvider.java
===================================================================
--- gradle-core/src/main/groovy/org/gradle/util/TimeProvider.java	Wed Feb 18 21:00:26 EST 2009
+++ gradle-core/src/main/groovy/org/gradle/util/TimeProvider.java	Wed Feb 18 21:00:26 EST 2009
@@ -0,0 +1,7 @@
+package org.gradle.util;
+
+public interface TimeProvider {
+
+    long getCurrentTime();
+
+}
Index: gradle-core/src/main/groovy/org/gradle/util/TrueTimeProvider.java
===================================================================
--- gradle-core/src/main/groovy/org/gradle/util/TrueTimeProvider.java	Wed Feb 18 20:59:54 EST 2009
+++ gradle-core/src/main/groovy/org/gradle/util/TrueTimeProvider.java	Wed Feb 18 20:59:54 EST 2009
@@ -0,0 +1,9 @@
+package org.gradle.util;
+
+public class TrueTimeProvider implements TimeProvider {
+
+    public long getCurrentTime() {
+        return System.currentTimeMillis();
+    }
+
+}
Index: gradle-core/src/main/groovy/org/gradle/util/Clock.java
===================================================================
--- gradle-core/src/main/groovy/org/gradle/util/Clock.java	(revision 1237)
+++ gradle-core/src/main/groovy/org/gradle/util/Clock.java	Wed Feb 18 23:03:36 EST 2009
@@ -21,21 +21,39 @@
  */
 public class Clock {
     long start;
+    private TimeProvider timeProvider;
 
+    private static final long MS_PER_MINUTE = 60000;
+    private static final long MS_PER_HOUR = MS_PER_MINUTE * 60;
+
     public Clock() {
+        this(new TrueTimeProvider());
+    }
+
+    protected Clock(TimeProvider timeProvider) {
+        this.timeProvider = timeProvider;
         reset();
     }
 
     public String getTime() {
-        return getTimeInMs() / 1000.0 + " secs";
+        StringBuffer result = new StringBuffer();
+        long timeInMs = getTimeInMs();
+        if (timeInMs > MS_PER_HOUR) {
+            result.append(timeInMs / MS_PER_HOUR).append(" hrs ");
-    }
+        }
+        if (timeInMs > MS_PER_MINUTE) {
+            result.append((timeInMs % MS_PER_HOUR) / MS_PER_MINUTE).append(" mins ");
+        }
+        result.append((timeInMs % MS_PER_MINUTE) / 1000.0).append(" secs");
+        return result.toString();
+    }
 
     public long getTimeInMs() {
-        return System.currentTimeMillis() - start;
+        return timeProvider.getCurrentTime() - start;
     }
 
     public void reset() {
-        start = System.currentTimeMillis();
+        start = timeProvider.getCurrentTime();
     }
 
 }
