Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2003-07-23 09:37:15


John Torjo wrote:
> I've been using date_time, and it's really cool!

Thanks.

> However, I would have a small request:
> For time iterators: we have hours(), minutes(), seconds(), but no days().
>
> Of course, instead of days(1) we can have hours(24), still I think it's more
> expressive to have days(1).

This 'discontinuity' with time_duration has been pointed out before, but
it really hasn't been a high priority to fix it.

> For instance, if I want to iterate 1 and a half days, I think it's more
> expressive to say:
>
> time_iterator it( start, days(1) + hours( 12)) instead of:
>
> time_iterator it( start, hours( 36))

It's pretty easy to add this yourself if you want:

class days : public boost::posix_time::time_duration {
   days(int day_count) :
      boost::posix_time::time_duration(day_count*24, 0, 0)
   {}
};

I didn't compile it, but this should work...

> Russell Hind wrote:
> Why not days(1.5) then? That would be even easier, wouldn't it?

Sure, but then we have to deal with rounding issues. To me the
compactness of this is not worth the trouble it creates.

Jeff


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