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

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

Thread Previous | Thread Next
John Peacock
January 14, 2003 10:33
Re: Parser Interface (Was Re: Picking up the ball)
Message ID:
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
> 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


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


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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About