On Tue, 14 Jan 2003, Martijn van Beers wrote:

> > > Looking at the two alternatives, does the second really seem clearer?
> > >
> > >    use DateTime;
> > >    my $dt = DateTime->new( 'MySQL' => $mysql_dt );
> > >    print $dt->to_string( 'MySQL' );
> > >
> > >    use DateTime;
> > >    use DateTime::Parse::MySQL;
> > >    my $dt = DateTime->from_mysql_datetime( $mysql_dt );
> > >    print $dt->to_mysql_string();
> >
> > Um, yeah, the second is _much_ clearer.  And its less error prone as well!
>
> Um, no it isn't.

Yes it is.  Your turn.

> > Your first option is not on the table.
>
> Let's put it on the table then. Much better than the other options.

No.  I already mentioned another option besides the second one up above.

  use DateTime;
  use DateTime::Parse::MySQL;
  my $dt = DateTime::Parse::MySQL->new_datetime( $mysql_dt );
  print DateTime::Parse::MySQL->mysql_datetime( $dt );

I can also imagine some other scheme, where parse/format modules register
the formats they can handle with DateTime.pm.

But I'm very strongly opposed to something that just passes random strings
into new() and then loads the module on demand.


-dave

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

Reply via email to