On 2010.8.22 1:25 PM, Karen Etheridge wrote:
> On Sun, Aug 22, 2010 at 12:19:52PM -0700, Michael G Schwern wrote:
>> Division works for every unit but months and years.  Perhaps it could be
>> implemented for durations that are only days/hours/minutes and throw an
>> exception if it contains a month or year?
>
> That's only approximately true. Some days contain 25 or 23 hours (consider
> the days where daylight savings switches over), and when a leap second is
> introduced, a minute can contain 61 seconds or a day can contain 86401
> seconds.  Context (an absolute date) is needed to perform these duration
> calculations correctly.

Good point.  I feel that's a level of accuracy that can be done without given
that durations are explicitly floating.  Its better to perform the division
with that slim caveat than not trying at all and leaving it up to the user to
muddle through and probably screw it up.

Or you allow fractional durations.  1 day / 1 hour = 1/24th of a day (not 1
hour).  Only when it is applied to a fixed datetime does it translate back.
Normally something like "2010-02-10 12:00" would become "2010-02-10 13:00"
when 1/24th of a day is added.  But if the date were DST then it would do...
uhh... something I can't quite figure out just now.


-- 
170. Not allowed to "defect" to OPFOR during training missions.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to