Hi Dave,
Passing bad parameters to either now() or today() causes errors to be returned with
from_epoch apearing as the callee.
"DateTime::from_epoch but was not listed in the validation options: ..."
I think this is a bit confusion during debugging and all the other constructors
(except clone) validate the passed params. While I'm hesitant to add the overhead I
thought it's worth suggesting. If you accept this I'll write the tests to match.
Cheers,
-J
--
Index: lib/DateTime.pm
===================================================================
RCS file: /cvsroot/perl-date-time/modules/DateTime.pm/lib/DateTime.pm,v
retrieving revision 1.223
diff -u -r1.223 DateTime.pm
--- lib/DateTime.pm 28 Jul 2003 06:05:27 -0000 1.223
+++ lib/DateTime.pm 28 Jul 2003 07:47:59 -0000
@@ -397,10 +397,28 @@
return $self;
}
+my $ToEpochValidate = {
+ locale => { type => SCALAR | OBJECT, optional => 1 },
+ language => { type => SCALAR | OBJECT, optional => 1 },
+ time_zone => { type => SCALAR | OBJECT, optional => 1 },
+};
+
# use scalar time in case someone's loaded Time::Piece
-sub now { shift->from_epoch( epoch => (scalar time), @_ ) }
+sub now
+{
+ my $class = shift;
+ my %p = validate( @_, $ToEpochValidate );
+
+ $class->from_epoch( epoch => (scalar time), %p );
+}
+
+sub today
+{
+ my $class = shift;
+ my %p = validate( @_, $ToEpochValidate );
-sub today { shift->now(@_)->truncate( to => 'day' ) }
+ $class->now( %p )->truncate( to => 'day' );
+}
sub from_object
{