On Tue, 14 Jan 2003, Stephen R. Wilcoxon wrote:

> > So given those constraints, here are the potential options on the table,
> > _so far_ (I welcome others that fit into the above constraints).
> >
> >   use DateTime;
> >   use DateTime::Parse::MySQL; # this needs a better name
> >   my $dt = DateTime::Parse::MySQL->new_datetime( $mysql_dt );
> >   print DateTime::Parse::MySQL->mysql_datetime( $dt );
> >
> > or
> >
> >   use DateTime;
> >   use DateTime::Parse::MySQL;
> >   my $dt = DateTime->from_mysql_datetime( $mysql_dt );
> >   print $dt->to_mysql_string();
>
> I prefer the second option of these two.  It's more compact and easier to
> read (to me).
>
> I wouldn't mind the first option either if "print $dt->mysql_datetime"
> would work instead of "print DateTime::Parse::MySQL->mysql_datetime($dt)".
> It's just too verbose.

The whole point of the first option is to _not_ add methods to the
DateTime package.

How about "$dt->representation('mysql')->mysql_datetime"?  That's a bit
better.  And representations could be added by having an output module
register itself with DateTime.pm.  But that API seems a bit unintuitive to
me.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to