Slash Boxes
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)

  (email not shown publicly)

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)

Wednesday February 12, 2003
08:51 AM

PL/SQL dates done right

[ #10543 ]

Today's gem from my O'Reilly Oracle books is that Oracle9i introduced TIMESTAMP and INTERVAL datatypes to provide more functionality than DATE alone could. It's always bothered me that arithmetic among DATEs gave you simple numbers, and that those numbers represented days and not something more granular.

Way back in 2000, after catching our few Y2K bugs that slipped past our audit, I began designing a Perl module to replace all of our date computations. I completely mapped out the API on my whiteboard in red marker, where it stayed for about six months. Drawing on experience with dBase IV of all things, I knew I needed an opaque object that represented a date. I named it Time::Stamp. I inferred for myself (I think; I don't recall having seen this anywhere else) that arithmetic among Time::Stamp objects would also require a Time::Interval class. Note anything interesting about that naming convention, compared to what Oracle did?

Of course, I never got time to implement much of my API, and then along came Matt Sergeant who invented Time::Object, later Time::Piece. Time::Object and Time::Seconds were almost exactly what I'd conceived of. Some method names were different, and there were some features I hadn't thought of, and a couple missing, but it wasn't vaporware! And the rest is history.

Nowadays I see exciting things ahead in the Perl datetime list. I notice the latest beta release of Time::Piece is reimplemented in terms of the new universal Perl time class.

Incidentally, I'm out of the group where I introduced the use of Time::Piece, but I did get to implement Time::Stamp. It's a subclass of Time::Piece (which wasn't easy to subclass for various reasons) with added convenience methods of yymmdd, yymmddhh, yymmddhhmm, etc. I think the new universal datetime classes are going to handle that.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Time::Piece has always had a ymd method that does that (and hms).
    • There was something wrong with it; can't remember what. Where "wrong" means "wasn't exactly what we needed." I also needed a constructor from YYMMDD[HH[MM]] timestamps when there was no strptime.

      Are you absolutely certain ymd was always there, from the beginning in Time::Object?

      Hmmm ... does some searching [] ...

      Ah! Oh, yes: ymd gave YYYY/MM/DD in those days, and I really needed no slashes and (for backward compatibility) two digit years. Hmm, still does [], but with hyphens now (customizable, presumabl

      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
      • BTW, I actually named my methods yymmdd, yymmddhh, etc. I always wanted to go back and do yyyymmdd, etc.

        J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers