1 #include <msp/strings/format.h>
8 using Msp::Time::RawTime;
10 string format_part(RawTime &value, RawTime unit, char sep, bool &first)
12 if(value<unit && first)
15 RawTime v = value/unit;
20 return Msp::format("%d", v);
23 return Msp::format("%c%02d", sep, v);
31 void operator<<(LexicalConverter &conv, const TimeDelta &td)
35 RawTime value = td.raw();
46 result += format("%dµs", value);
47 else if(value<1000000)
49 result += format("%d", value/1000);
52 result += format(".%03d", value);
58 bool unit = value<60000000LL;
59 result += format_part(value, 86400000000LL, 0, first);
60 result += format_part(value, 3600000000LL, '-', first);
61 result += format_part(value, 60000000LL, ':', first);
62 result += format_part(value, 1000000LL, ':', first);
67 result += format(".%06d", value);
69 result += format(".%03d", value/1000);