On Thu, 16 Jan 2003, Nick Tonkin wrote: > Umm, improper grammar caused by hasty response caused by a teensy-weensy > overdose of hubris? Everyone is in awe of your commitment and energy, Dave > ... sometimes you're becoming a bit short with folks, though ...
Sorry. I get frustrated when people respond only to my message, without reading the long thread it's in. I'll be more polite in the future. > You wouldn't have to type that more than once, would you? Any code that > needs to be used more than once should be wrapped in a sub anyway. And > besides, > > my $dt = DateTime->parser('MySQL')->from_datetime( $mysql_dt_string ); > > appears to be longer than > > my $dt = DateTime::Formats::MySQL->parse( $mysql_dt_string ); > > as well as less clear. Hmm, maybe. But then I wondered what if we need to give arguments to the parser or formatter, and don't want to give them on every parse/format call. Which means that they should be object, not class methods, and the constructor would receive those "permanent" arguments. > > It also has the additional side effect of allowing you to create and hold > > onto formatters and parsers. > > Not an issue if you write a three-line function. Sure, but maybe useful in the above case. Ok, how about this then: my $format = DateTime::Formats::MySQL->new( ... ); my $dt = $format->parse_datetime( $mysql_dt ); $format->as_timestamp( $dt, length => 8 ); # although I dislike mixing position and named params so maybe ... $format->as_timestamp( datetime => $dt, length => 8 ); -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/