Hi Jeff, Told you I'd come back for more ;) Here are some more improvements I would consider useful:
[1] unary operator-(time_iterator). Example: -hours(24) instead of hours(-24). (seems more straightforward) note: hours(24) can be also written as: hours(0) - hours(24) but look ugly [2] Does a *FOUR* functions justify having a jam file? (greg_month::as_short_string(), greg_month::as_long_string(), greg_weekday::as_short_string(), greg_weekday::as_long_string()) They could definitely be made static or something. (or the user could be given a choice - using the date_time from a .jam-generated dynamic link library, or directly) [3] I've been recently involved in a project that used to use raw time_t's. A conversion to/from time_t would come in very handy. (at least one way would be enough). I've created such a function: #include <boost/date_time/posix_time/posix_time.hpp> // converts raw time to cool ptime structure inline boost::posix_time::ptime rawtime_to_ptime( time_t raw) { using namespace boost::posix_time; using namespace boost::gregorian; tm details = *localtime( &raw); date day( details.tm_year + 1900, details.tm_mon + Jan, details.tm_mday); time_duration offset( details.tm_hour, details.tm_min, details.tm_sec, 0); return ptime( day, offset); } pretty simple and straightforward, I think. [4] time_duration::fractional_seconds() seems pretty confusing. As I understood by looking at the docs, fraction actually means nano-seconds. Why not use time_duration::nano_secons() instead? (at first, I did not know what fractional_seconds meant) [5] In file gregorian_calenar.hpp, you #include "gregorian_calendar.ipp" I think to make it more portable, it should be: #include <boost/date_time/gregorian/gregorian_calendar.ipp> [6] documentation - does not say if greg_day starts from one or zero (from experiments, I realized it starts from one) Maybe this is not so important, but was confusing for me at first. [7] I think a wrapper like I've attached would be pretty useful for dealing with time values - mainly for testing/debugging. (as a matter of fact, this simple wrapper helped me a lot catch a few bugs from code written by others. all I had to do was replace time_t with time_t_wrapper<>) Short description: - this allows writing times (to streams) in a user-friendly manner: besides the time_t value, a *word* that shows what the time_t value means. - also, reading these values from streams can be done using the '>>' operator. The cool thing is that both time_t and time_t_wrapper<> values can be read from a stream. time_t_wrapper<> can be used in two modes: - debug mode - release mode (time_t_wrapper<> can be as efficient as time_t in release mode) In debug mode, each value contains a user-friendly string corresponding to the time_t value. As a side-note, this could be made much more general, to work for other HANDLE-like types (for instance, HWND in Win32 or so). What do you think? Best, John -- John Torjo -- "Practical C++" column writer for builder.com.com Freelancer, C++ consultant mailto:[EMAIL PROTECTED]
time_t_wrapper.h
Description: Binary data
time_t_wrapper.cpp
Description: Binary data
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost