develooper Front page | perl.datetime | Postings from January 2003

Re: Parser Interface (Was Re: Picking up the ball)

Thread Previous | Thread Next
From:
John Peacock
Date:
January 14, 2003 10:33
Subject:
Re: Parser Interface (Was Re: Picking up the ball)
Message ID:
3E245809.5000108@rowman.com
Dave Rolsky wrote:
>   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.
> 

I guess that is the part that I don't understand.  If you have the ability to 
add new parsing methodology to a list, you can just as easily subtract.  So, if 
you want to use only the basic parsing and throw an error if you get a 
non-standard date format:

     use DateTime ( parse => basic); # class-wide default
     my $date1 = DateTime->new($dtstring); # better be ISO CCYYMMDD
     my $sqldate = DateTime->new($sqlstr, parse => MySQL); # object override

etc.

This is a much more friendly interface for the average programmer.

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About