"Jeff Garland" <[EMAIL PROTECTED]> writes: > On Tue, 02 Sep 2003 19:00:42 -0400, David Abrahams wrote >> The "fractional seconds" concept is undocumented. My guess it's >> something like: >> >> x.fractional_seconds() == x.ticks() % seconds(1).ticks() >> >> This needs to be nailed down. > > Yep the docs don't say enough on this. > > Basically, time durations are represented as a count at a compile-time > specified resolution. That is, a count of 1 can represent a millisecond, > nanosecond, femtosecond (just to pick one ;-), or whatever. So fractional > seconds is a generic way of handling the sub-second remainder of these without > having to provide every possible combination.
Uh-huh. So is my formula above correct or not? > That is, the fractional seconds provides the count of 'whatever time > units' that are left over after stripping away the duration greater > than a second. I don't think you really mean "greater than". I suggest that instead of plain English you try to document a formal definition, like I did. > To really use fractional_seconds you call the resolution traits by > calling: > > time_duration::rep_type::res_adjust() Where is *that* documented? > This method provides you with the count of fractional seconds used > by the time duration. This little program might illustrate > things... > > //print_resolution.cpp > #include "boost/date_time/posix_time/posix_time.hpp" > #include <iostream> > > //Must match with time_resolutions enum in date_time/time_defs.h > const char* const resolution_names[] = {"Second", "Deci", "Centi", "Milli", > "Ten_Thousanth", "Micro", "Nano"}; > > > int > main() > { > using namespace boost::posix_time; > > std::cout << "Resolution: " > << resolution_names[time_duration::rep_type::resolution()] > << " -- Ticks per second: " > << time_duration::rep_type::res_adjust() << std::endl; > > } > > //output > Resolution: Micro -- Ticks per second: 1000000 I'm sorry, that's really nasty. Why wouldn't I just do seconds(1).ticks() ?? >> Also, the assymetry of those nice Construction by Count factories >> down to nanosec(x) with the accessors which only include units down >> to seconds() but not millisec()...nanosec() is disturbing and >> frankly inconvenient. > > Ok, but I'm interested in your use case as once I have a > time_duration I don't normally care about a particular sub-second > resolution. OK, well I do. I'm porting some Java code which uses times in whole milliseconds, and when a time gets written to disk I need to write the number of milliseconds to maintain a compatible format. > But now that I think about it would seems like it might > be possible to provide the inverse interface... Yeah, easy even. >> BTW, why plural hours, minutes, seconds, but singular millisec, >> microsec, nanosec? > > Yikes! They probably all should be plural. Problem is the abbreviated > 'millisecs' doesn't sound right to me, so perhaps that's the reason.... Well, abbrevs just don't sound right. Bite the bullet and use the full names, please! -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost