-/*
+/* $Id$
+
This file is part of libmspcore
Copyright © 2006 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
+
#include <sstream>
#include <iomanip>
#include "timedelta.h"
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;
}
}
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)
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);