[gparted] Fix formatting of negative time values (#760709)



commit b0bd4650982f5c804eae24eb59ec8ac015be5ba1
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Jan 15 22:41:45 2016 +0000

    Fix formatting of negative time values (#760709)
    
    ... to display a negative sign before the hours, minutes and seconds.
    Before:
        Utils::format_time(-1)   = "00:00:0-1"
        Utils::format_time(-119) = "00:0-1:0-59"
    After:
        Utils::format_time(-1)   = "-00:00:01"
        Utils::format_time(-119) = "-00:01:59"
    
    Bug 760709 - Add progress bars to XFS and EXT2/3/4 file system specific
                 copy methods

 src/Utils.cc |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/Utils.cc b/src/Utils.cc
index 5c22d7d..165c13b 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -447,6 +447,12 @@ Glib::ustring Utils::format_time( std::time_t seconds )
 {
        Glib::ustring time ;
 
+       if ( seconds < 0 )
+       {
+               time = "-";
+               seconds = -seconds;
+       }
+
        int unit = static_cast<int>( seconds / 3600 ) ;
        if ( unit < 10 )
                time += "0" ;


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