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 ]

VSarkiss (704)

VSarkiss
  (email not shown publicly)
Yahoo! ID: vah3sark (Add User, Send Message)

I haven't really taken the time to set this up, but you can look at my home node [perlmonks.org] on Perl Monks.

Journal of VSarkiss (704)

Thursday May 15, 2003
09:52 PM

Gah! Dates must be simpler

[ #12233 ]

Dave Rolsky wrote an article a while back about how there are too many date-handling modules in CPAN. When I read it, I thought, "Absolutely, an overhaul is really needed."

Tonight I was reminded once again how bad the situation really is. There are too many modules, alternating between too much and too little. (Just "too", as in "too many notes!") What happened to "simple things should be simple, complicated things should be possible"?

I had six rows of dates, and all I wanted was, "Give me the next business day". After twenty minutes of floundering around with Date::Calc and Date::Calendar and their kin, I gave up, and just looked up each row in a real calendar: "Lessee, Memorial day is the 26th, so it's Tuesday."

I know someone will post a reply of "Just use Date::Foobar" or "In Date::Calc, just get the date in Tasmania and subtract the phase of the moon." You know what? By the time I got through the docs, wading through how to figure the Coptic calendar and the umpteen routines to calculate Easter, I was just too fed up to continue. Do the people that wrote this stuff really use it? Or did they just throw the kitchen sink in there because they could?

I hope the DateTime group makes things better, but frankly, glancing at the modules page makes me wonder if they're just adding fuel to the fire. "Baby Time"? "Pataphysical Calendar"? Yeah, those will be really useful.

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.
  • I'm coming to believe that one of the fastest ways of converting a string date to an integer is via table lookup. Look at the string just long enough to figure out which table (or hash, or whatever) to do the lookup from, then use the string as a key. A classic space-for-time trade-off. And with ~365.25 distinct dates per year, it's really not all that much space to deal with 20 years worth of days, even in multiple formats.
  • Core modules (Score:3, Informative)

    Odds are, you won't ever need a DateTime::Calendar module.

    Odds are, you won't ever need half the Format modules.

    DateTime itself, DateTime::(Set|Span), and probably one or two of the format modules (probably Strptime or Builder since they're the most generic), are all most people will need. [Though Builder needs some refactoring since its simple cases have gotten a bit too complex.]

    I don't think anyone's bothered to write business day stuff yet. Contributions are welcome, of course =) I think someone was working on representing holidays and such, which would be useful for such a module.

    Join the list [perl.org]! =)
    --
      ---ict / Spoon
  • Give me the next business day
    Well, actually, you happen to pick one of the harder problems just then. You can state the problem easily, but then you have to answer a lot of questions:
    • What business?
    • What part of the world?
    • What exceptions?
    So, while it seems easy at first, it's one of the more difficult issues.
    --
    • Randal L. Schwartz
    • Stonehenge
    • Exactly, I realize it's nontrivial; that's why I went to find a module rather than roll my own. My point was that the interface and documentation were so complicated that the modules ended up not being of any help. As a contrasting example, CGI parameter parsing can be tricky, but CGI.pm packages up the difficulty for you, giving you a simple interface. That's not the case here.

  • What we really need is a date/time handling module that is also a text templating system.
    --

    --
    xoa

  • I have always just used Date::Manip [cpan.org] it even has &Date_NextWorkDay. Dunno if that helps, or complicates issues :-)
    --
    andrew
    • Except that its huge and written in pure Perl, thus can be slower than smaller modules or ones written in C.

      However, as I have yet to find a working Win32 version of DateTime, [cpan.org] Date::ICal [cpan.org] does a pretty good job.