Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

jdavidb
  (email not shown publicly)
http://voiceofjohn.blogspot.com/

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Tuesday August 07, 2007
02:57 PM

More DateTime damage

[ #34033 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.