
Rutger ter Borg wrote:
Andrey Semashev wrote:
What exactly is wrong?
Streaming of a time duration is broken; IMHO the snippet below shouldn't be asserted on. To make things consistent, alternatives could be to impose a limit of 100 hours in the concept of a time duration, to introduce a limited_time_duration concept, to follow ISO 8601, or to allow more than 99 hours.
time_duration a = hours( 10 ); // OK std::cout << a << std::endl; // OK
time_duration b = hours( 100 ); // OK std::cout << b << std::endl; // Assertion failure
The assertion is there because the default time duration format is "%H:%M:%S". This is exactly what I'm proposing to change. I think it should be "%O:%M:%S" thus imposing no restrictions on the hours field of a time duration. Actually, I can not find a notion of a limited time duration in ISO 8601-2004. Instead the third paragraph of section 4.4.3.2 says the following:
In these representations the maximum number of digits in a component needs to be agreed by the partners in information interchange.
Suggesting that time durations may have variable number of digits for all fields.