]> git.tdb.fi Git - libs/core.git/blobdiff - source/time/timedelta.cpp
Merge branch 'strings-master'
[libs/core.git] / source / time / timedelta.cpp
index f7b037ea7d154dac0e7b931106fbd2932a1dbbba..c74ffcef4f71fa08de3124b65c1c5171e721da80 100644 (file)
@@ -1,8 +1,10 @@
-/*
+/* $Id$
+
 This file is part of libmspcore
 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
+
 #include <sstream>
 #include <iomanip>
 #include "timedelta.h"
@@ -12,17 +14,19 @@ using namespace std;
 
 namespace {
 
-void print_part(ostream &out, int64_t &value, int64_t unit, char sep, bool &first)
+using Msp::Time::RawTime;
+
+void print_part(ostream &out, RawTime &value, RawTime unit, char sep, bool &first)
 {
-       if(!value || (value<unit && first))
+       if(value<unit && first)
                return;
        
        if(!first)
                out<<sep<<setw(2);
        
        out<<value/unit;
-       value%=unit;
-       first=false;
+       value %= unit;
+       first = false;
 }
 
 }
@@ -35,12 +39,12 @@ ostream &operator<<(ostream &out, const TimeDelta &td)
        ostringstream ss;
        ss.fill('0');
 
-       int64_t value=td.raw();
+       RawTime value = td.raw();
 
        if(value<0)
        {
                ss<<'-';
-               value=-value;
+               value = -value;
        }
 
        if(value==0)
@@ -50,14 +54,14 @@ ostream &operator<<(ostream &out, const TimeDelta &td)
        else if(value<1000000)
        {
                ss<<value/1000;
-               value%=1000;
+               value %= 1000;
                if(value)
                        ss<<'.'<<setw(3)<<value;
                ss<<"ms";
        }
        else
        {
-               bool first=true;
+               bool first = true;
                print_part(ss, value, 86400000000LL,  0,  first);
                print_part(ss, value, 3600000000LL,  '-', first);
                print_part(ss, value, 60000000LL,    ':', first);