On Fri, 21 Mar 2003, Iain 'Spoon' Truskett wrote:
> Morning all,
>
>
> Wander over to
>
> http://perl.dellah.org/modules/
>
You wrote that in a couple of hours???
> and have a look at DateTime::Format::Builder. It's not finished.
>
> The docs need work, it needs more tests, and it's missing some features.
> (And the tests to test the missing features.)
I'll try to work on this tonight.
> I'm about to sleep and won't get a chance to play with it for quite a
> few hours, so patches, advice, etc. are welcome.
>
> I admit I think I got a bit carried away. =)
Yes, you did.
It looks like a great start.
I still think that using the length as a hash key could lead to unexpected behavior.
Consider:
my $new_parser = DateTime::Format::Builder->create_parser(
8 => {
params => [ qw( year month day ) ],
regex => qr/^(\d\d\d\d)(\d\d)(\d\d)$/,
zero => { hour => 0, minute => 0, second => 0 },
},
.
.
8 => {
params => [ qw( month day year ) ],
regex => qr/^(\d\d)(\d\d)(\d\d\d\d)$/,
zero => { hour => 0, minute => 0, second => 0 },
},
);
Maybe this would be safer?
{
length => 8,
params => [ qw( month day year ) ],
regex => qr/^(\d\d)(\d\d)(\d\d\d\d)$/,
zero => { hour => 0, minute => 0, second => 0 },
},
Maybe I'm just paranoid...
DateTime::Format::Builder->create_class(
class => 'DateTime::Format::MySQL',
This scares me. :) The namespace collisions could be spectacular.
--
--- Builder.pm Thu Mar 20 03:23:33 2003
+++ new.Builder.pm Thu Mar 20 13:26:09 2003
@@ -117,7 +117,8 @@
C<create_class> is different from the other constructors. It creates a
full class for the parser, not just an instance of
-C<DateTime::Format::Builder>.
+C<DateTime::Format::Builder>. Please consider the dangers of namespace
+pollution when using this.
For example:
--
And maybe change 'Class' to 'Namespace' to be super clear about what is happening.
Cheers,
-J