More DateTime damage

jdavidb on 2007-08-07T19:57:17

Well, we've been aware of the problems forever and chosen not to fix them. As somebody said here recently, the developers know exactly why the module evolved the way it did and works the way it does and how to do what they want, but the users only see the public interface and can only use that to figure out how to do what they want to do.

DateTime::Duration is a useless piece of manure for my purposes. Sometimes it gets me what I want, but not often, and when it does I always have an uneasy feeling that it didn't really do what I wanted. Apparently the solution is expressed in that linked message, (from 2004), that what should be provided is the "stopwatch duration." Yes, of course. What the heck else are you providing? Whatever it is, it isn't helping me.

Well, division doesn't really work, whether you do it as multiplication or not ;) What is half a minute? How long is half a month?

Half a minute is 30 stinkin' seconds. Half a month is a little harder, but if I'm adding half a month to a moment in time, then the code can figure out exactly what it is.

I need a class that works with DateTime and represents a meaningful, usable interval of time. Oracle has these. Time::Piece has these. There's even an ISO standard for representing them. So why doesn't DateTime, Perl's preferred date/time handling system, have them?

Please, somebody respond with cursing and helpful information I could've found myself if I'd looked harder. :)

Update: It appears that the problem is that subtraction between DateTimes is overloaded to the subtract_datetime method, which produces the DateTime::Duration objects that I cannot use (I presume they are useful to somebody), instead of to the subtract_datetime_absolute method, which produces DateTime::Duration objects which I can use. Apparently my brain works differently, or the cases I want to deal with are just very different from the norm. I have trouble believing this, but it must be so. But clearly others have had trouble with this, and as the message I linked to shows, some have felt that newbies are going to think the same way I do.