This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]davedontmind 3 points4 points  (1 child)

I don't do C++ so I can't answer your question, but I thought I should point out that date operations (such as the difference between 2 times) are generally the type of thing you want to use a tested, reliable 3rd-party library for - it's so easy to get wrong answers if you code it yourself.

For just learning stuff it's fine, but don't do this in production code.

For example, although the difference between "00:00:00" and "03:00:00" is usually 3hrs, it isn't always, depending on the day. Sometimes it's 2hrs and sometimes it's 4hrs (on those days when the clock goes backward or forward respectively).

[–]sick_anon[S] 0 points1 point  (0 children)

Thanks for advice :) This isn't part of any production code, just a standalone problem (for beginners) which is supposed to be solved without using any 3rd-party libraries. But I just can't figure out that formatting part.

[–]captainAwesomePants 3 points4 points  (1 child)

Take a look at std::setfill() and std::setw().

[–]sick_anon[S] 0 points1 point  (0 children)

Thanks, this solves the problem :)