Joshua Hoblitt schreef: > > >What you want is to normalize the values of a duration relative to > > >some fixed point in time. I agree this is something that we need to > > >do. Patches are welcome. :) > > > > So if I read this correctly the answer is at this time what I'm after > > is not possible with DateTime directly. But, what I request is > > something you all desire and hope to have working when someone has > > the time. I actually wouldn't mind taking a look to see if I could > > contribute but at this point if: > > You are getting the _correct_ answer. Let me say that again. You are > getting the _correct_ answer. The information is exactly what you > asked for. It just not in the units that you want.
No, he's getting _a_ correct answer. The information is _not_ what he has asked for. 2003-08-23 minus 1970-08-23 is both equal to 23 years, and to 12053 days, even though 23 years is very much different from 12053 years. > The units that > you are asking for are of variable length and depend on the context in > which they are used. Days also have a variable length. Only DT::Duration's that contain only a 'seconds' component represent time intervals of constant length. The reason why DT::subtract_datetime returns a DT::Duration with days and seconds, is the way DT's are implemented internally: rd_days and rd_seconds. It's easier and faster to just subtract these values. > It is not a stub. It should not produce 35. You really don't seem to > believe me but the behavior is _correct_. What you are asking for is > a DT::Duration relative to DateTime and the infrastructure simply > doesn't exist yet. The infrastructure does exist: a DT::Duration can contain years (actually, it contains months; but the conversion months <=> years is unique), and a DT of say 2 years and 3 months already is relative to DateTime. The only problem is that DT::subtract_datetime doesn't use it. It probably should. (It would be even better if there was an option to calculate the difference in days & secs. But the default should probably be to return a difference of months, days, minutes, seconds.) Eugene