Returning Time as strings--Help

I want to return Hours:Minute:Seconds as a string for GUI reasons. How can I do it using the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  void digital_display()
{
    typedef duration<int, ratio_multiply<hours::period, ratio<24> >::type> days;
    system_clock::time_point now = system_clock::now();
    system_clock::duration tp = now.time_since_epoch();
    days d = duration_cast<days>(tp);
    tp -= d;
    hours h = duration_cast<hours>(tp);
    tp -= h;
    minutes m = duration_cast<minutes>(tp);
    tp -= m;
    seconds s = duration_cast<seconds>(tp);
    tp -= s;
    std::cout<<h.count() << ':'
              << m.count() << ':' << s.count();

}


Are there alternative? I feel this is a messy way.
Last edited on
Topic archived. No new replies allowed.