1 #include <msp/strings/format.h>
9 using Msp::Time::RawTime;
11 string format_part(RawTime &value, RawTime unit, char sep, bool &first)
13 if(value<unit && first)
16 RawTime v = value/unit;
21 return Msp::format("%d", v);
24 return Msp::format("%c%02d", sep, v);
32 void operator<<(LexicalConverter &conv, const TimeDelta &td)
36 RawTime value = td.raw();
47 result += format("%dµs", value);
48 else if(value<1000000)
50 result += format("%d", value/1000);
53 result += format(".%03d", value);
59 bool unit = value<60000000LL;
60 result += format_part(value, 86400000000LL, 0, first);
61 result += format_part(value, 3600000000LL, '-', first);
62 result += format_part(value, 60000000LL, ':', first);
63 result += format_part(value, 1000000LL, ':', first);
68 result += format(".%06d", value);
70 result += format(".%03d", value/1000);