
On Thu, 21 Jul 2005 22:28:08 +0200, Friedrich Wilckens wrote
Hi,
the concept of the length of generic periods puzzles me. The "normal" case p.length() = p.end() - p.begin() makes sense to me, but why is a period with last() == begin() treated as a special case, having length 0?
Long ago in a mailing list somewhere the issue of null intervals appeared and that's where this logic came from...
Having this special case make the length concept behave strangely. For example, [2005-May-1/2005-May-1] has length 0,
Well, that seems incorrect [2005-May-1/2005-May-1) has length zero (Note the non-inclusive end). But, then again, what is the duration of [1,1] -- zero I believe.
but [2005-May- 1/2005-May-2] has length 2!
Hmm.
Actually there is no period of length 1 at all.
Oh my...that doesn't seem right at all....
As I understand from the documentation, the philosophical reason behind this seems to be that the end points of periods are considered "points" and that a point and therefore a period that consists of a single point has zero extension.
This sounds plausible if you think of the periods like intervals on the real number line. But our situation is different, I think, since we always deal with discrete quantities that have a finite length (or "duration").
Actually, I don't think it is different from an 'integer numberline'.
I would interpret the period [2005-May-1/2005-May-1] as the time period that lasts during the whole day 2005-May-1, from 00:00 up to 23:59:59.999... Therefore, I would give it the length (duration) 1.
Yes, that seems correct except that a date-period cannot represent anything less than a single day. Just as integers in a range [1,1] cannot represent 1.99999.
[2005-May-1/2005-Apr-30] would accordingly be an empty period of length 0, and [2005-May-1/2005-Apr-29] would be an invalid period of length -1.
The length of a date_period p would then be simply the number of days in p, multiplied with the unit of the duration_type. The template parameter duration_type can be used to defined different measurements of the length. In the standard case (duration of a day is 1) you measure the period length in days. But you could also measure it in seconds, by using a duration_type with unit() = 86400.
What do you think about this?
I'm worried that there is a problem here, but I'm going to need some time to look at it. I won't be able to for a couple days... Jeff