[gnome-clocks] Make sure split times are consistent with total times



commit b5059d963c1f1d3fd4ef3c612eedaa8ea540a752
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Aug 24 11:48:48 2013 +0200

    Make sure split times are consistent with total times
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706318

 src/stopwatch.vala |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/stopwatch.vala b/src/stopwatch.vala
index 9ea3cfb..27cdea5 100644
--- a/src/stopwatch.vala
+++ b/src/stopwatch.vala
@@ -220,7 +220,13 @@ public class MainPanel : Gtk.Box, Clocks.Clock {
         current_lap += 1;
         var e = timer.elapsed ();
         var split = e - last_lap_time;
-        last_lap_time = e;
+
+        // Discard milliseconds in the saved lap time to ensure
+        // total and split times are consistent: for instance if we saved
+        // 0.108000 and the next lap is 1.202000, we would see on screen 0.10
+        // and 1.20, so we would expect a split time of 1.10, but we would
+        // instead get 1.094000 and thus display 1.09
+        last_lap_time = Math.floor(e * 100) / 100;
 
         int h;
         int m;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]