Dave,
Here is a small patch that allows you to create a DT::Language object by just calling
new on it (and thus not being trapped into the DT::Language namespace).
This should tie me over until locale is officially released. :)
-J
--
Index: lib/DateTime/Language.pm
===================================================================
RCS file: /cvsroot/perl-date-time/modules/DateTime.pm/lib/DateTime/Language.pm,v
retrieving revision 1.15
diff -u -r1.15 Language.pm
--- lib/DateTime/Language.pm 27 Apr 2003 23:40:47 -0000 1.15
+++ lib/DateTime/Language.pm 10 Jun 2003 08:02:11 -0000
@@ -38,10 +38,15 @@
{
my $class = shift;
my %p = validate( @_,
- { language => { type => SCALAR } },
+ { language => { type => SCALAR, optional => 1 } },
);
- my $real_class = $class->load( $p{language} );
+ my $real_class;
+ if ( defined $p{ language } ) {
+ $real_class = $class->load( $p{language} );
+ } else {
+ $real_class = $class;
+ }
my $obj = bless {}, $real_class;
@@ -177,7 +189,8 @@
after a dash, so things like "en" or "en-us" are both legal. If a
country code is given, then the most specific match is used. For
example, if "en-au" (English, Australian) is given, then the nearest
-match will be "en", which will be used instead.
+match will be "en", which will be used instead. If the "language"
+parameter is omitted then an object of the called class is created.
=item * load( $language )
Index: t/14language.t
===================================================================
RCS file: /cvsroot/perl-date-time/modules/DateTime.pm/t/14language.t,v
retrieving revision 1.6
diff -u -r1.6 14language.t
--- t/14language.t 7 May 2003 17:23:23 -0000 1.6
+++ t/14language.t 10 Jun 2003 08:02:11 -0000
@@ -11,7 +11,7 @@
my @codes = DateTime::Language->iso_codes();
push @codes, 'en-us', 'en-uk';
-plan tests => 1 + scalar @codes + ( scalar @langs * 2 );
+plan tests => 2 + scalar @codes + ( scalar @langs * 2 );
foreach my $lang ( sort @langs, sort @codes )
{
@@ -30,3 +30,8 @@
eval { DateTime->new( year => 1900, language => 'fo-ba' ) };
like( $@, qr/unsupported/i, "try loading invalid language via ISO code" );
+
+{
+ my $dtl = DateTime::Language::English->new();
+ isa_ok( DateTime->now( language => $dtl ), 'DateTime' );
+}