Boost logo

Boost :

From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2003-08-06 12:11:20


[Jeff Garland]
> Hmm, I agree that this is not nice...

Ok.
 
> The downside of this is that when you are printing a time duration:
> std::cout << td.hours() << ':' << td.minutes() << ':' << td.seconds();
> you have to take remove the sign from the minutes and seconds.
> I have a third suggestion:
> - Implement (1) using abs() in the hours() method
> - Add a total_seconds function to the library so you don't have to write
> it.

How about:

* Implement (2), making all components negative if the time_duration is
negative
* Add a total_seconds() fxn so users don't have to write it
* Allow users to lexical_cast<string> a time_duration so it can be printed
as "-5:34:22" and document this so that users don't try to roll their own
naively.

Some unrelated issues that have come to me while working with date_time:

* The documentation could stand some revision. There's apparently daylight
saving time stuff in the code, but it's not documented at all.

* It's also not obvious from the documentation where things like January and
Tuesday live. This applies generally; it's not obvious what namespace many
functions and classes live in.

* I looked at the code and determined that Sunday = 0 (it's an enumeration),
but it'd be nice if this were guaranteed in the documentation.

* One example shows:
last_kday_of_month lkm(Monday,Jan);
date d = lkm.get_date(2002);//2002-Jan-28

I found that I had to write:
first_kday_of_month<date>(Sunday, Apr).get_date(2002)

Shouldn't the fact that first_kday_of_month and its ilk are templated be
documented? I was confused why I have to template it on date in the first
place (what else would go there?).

Stephan T. Lavavej
http://stl.caltech.edu


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk