Hello!

I just recently found the DateTime project after spending a good week
studying international standards, chapters in various perl books, and the
various existing modules in CPAN.  I was disastisfied with all existing
solutions, and was just about to start coding my own date object when I
finally stumbled on Rolsky's perl.com article, which then let me to
datetime.perl.org.

I'm reading through the FAQ now, and I swear, my eyes are tearing up from
the beauty of it all.  I'm thrilled to see that someone is finally
developing a well-thought-out, well-designed, comprehensive solution to the
problem of working with dates and times in software.

Of course, I can never leave well-enough alone, so here are a few questions
that occurred to me while reading the FAQ.  I tried looking up some of this
stuff on the mailing list archive without much luck, so I apologize if this
has already been discussed before.


1) Why have different 'new' and 'from_epoch' constructors?  Couldn't one
always use 'new' and have the module figure out what information to
initiatlize itself with by seeing if either the 'year' or 'epoch' name
parameter was passed?  I think it would provide a cleaner and more
consistent interface.

Instead of:

my $date1 = DateTime->new( year  => 2003
                           month => 1,
                           day   => 1,
                          );
my $date2 = DateTime->from_epoch( epoch => time() );

You could do this:

my $date1 = DateTime->new( year  => 2003
                           month => 1,
                           day   => 1,
                          );
my $date2 = DateTime->new( epoch => time() );


2) However, if you continue to provide different constructors, then when
using from_epoch, why require the 'epoch' named paramter?  Why not assume a
single argument is an epoch value?

Instead of:

my $date = DateTime->from_epoch( epoch => time() );

You could do this:

my $date = DateTime->from_epoch( time() );


3) I copied the following code from the Strptime example in Section 2.7 of
the FAQ:

Instead of:

# prints '2003-05-04 12:55:10';
print $dt->ymd . ' ' . $dt->hms;

You could offer one or more of these:

# prints '2003-05-04 12:55:10';
print $dt->ymd_hms;
print $dt->ymdhms;
# prints '2003-05-04 12:55:10.123456789';
print $dt->ymdhmsn;


4) From section 6.13: "How do I find yesterday's Date?"

Instead of:

my $dt = DateTime->now()->subtract( days => 1 );

Why not add the two most popular uses as convenience functions:

my $dt = DateTime->yesterday();
my $dt = DateTime->tomorrow();

This would be especially useful in business environments where half of the
code that runs daily runs to process the previous day's data (like web
logs), and so yesterday's date is often the first thing calculated in a
script.


Anyway, great job, guys!

Also, is anyone working on Sybase support for DateTime::Format::DBI?

-ofer

Reply via email to