[gnome-sudoku] Show puzzle completion time in minutes only



commit 6f9e946f3182c69364c849e74dc11ec6900b2ef3
Author: Parin Porecha <parinporecha gmail com>
Date:   Thu Aug 14 11:17:55 2014 +0200

    Show puzzle completion time in minutes only
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731139

 lib/sudoku-game.vala  |   29 ++++++-----------------------
 src/gnome-sudoku.vala |    2 +-
 2 files changed, 7 insertions(+), 24 deletions(-)
---
diff --git a/lib/sudoku-game.vala b/lib/sudoku-game.vala
index 0cfb44e..234ef38 100644
--- a/lib/sudoku-game.vala
+++ b/lib/sudoku-game.vala
@@ -118,35 +118,18 @@ public class SudokuGame : Object
         return board.previous_played_time + timer.elapsed ();
     }
 
-    public static string seconds_to_hms_string (double time_in_seconds)
+    public static string seconds_to_minutes_string (double time_in_seconds)
     {
-        var SECOND = _("second");
-        var SECONDS = _("seconds");
         var MINUTE = _("minute");
         var MINUTES = _("minutes");
-        var HOUR = _("hour");
-        var HOURS = _("hours");
 
-        string[] time_array = {};
-        var seconds = (int) time_in_seconds;
-        var hours = seconds / 3600;
-        var hour_string = (hours == 1) ? HOUR : HOURS;
+        var minutes = (int) time_in_seconds / 60;
+        if (minutes == 0)
+            minutes = 1;
 
-        seconds = seconds % 3600;
-
-        var minutes = seconds / 60;
         var minute_string = (minutes == 1) ? MINUTE : MINUTES;
+        var time_string = "%d %s".printf (minutes, minute_string);
 
-        seconds = seconds % 60;
-        var second_string = (seconds == 1) ? SECOND : SECONDS;
-
-        if (hours != 0)
-            time_array += "%d %s".printf (hours, hour_string);
-        if (minutes != 0)
-            time_array += "%d %s".printf (minutes, minute_string);
-        if (seconds != 0)
-            time_array += "%d %s".printf (seconds, second_string);
-
-        return string.joinv (", ", time_array);
+        return time_string;
     }
 }
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index b0ece3d..bb5ceeb 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -241,7 +241,7 @@ public class Sudoku : Gtk.Application
 
         game.board.completed.connect (() => {
             var time = game.get_total_time_played ();
-            var time_str = SudokuGame.seconds_to_hms_string (time);
+            var time_str = SudokuGame.seconds_to_minutes_string (time);
 
             for (var i = 0; i < game.board.rows; i++)
                 for (var j = 0; j < game.board.cols; j++)


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