[Bps-public-commit] r9687 - in Date-Extract: lib/Date

sartak at bestpractical.com sartak at bestpractical.com
Thu Nov 15 21:59:28 EST 2007


Author: sartak
Date: Thu Nov 15 21:59:27 2007
New Revision: 9687

Modified:
   Date-Extract/   (props changed)
   Date-Extract/lib/Date/Extract.pm

Log:
 r45249 at onn:  sartak | 2007-11-15 21:58:23 -0500
 Various fixes. Can't use max and min because they don't check for overloading, so we have to use reduce


Modified: Date-Extract/lib/Date/Extract.pm
==============================================================================
--- Date-Extract/lib/Date/Extract.pm	(original)
+++ Date-Extract/lib/Date/Extract.pm	Thu Nov 15 21:59:27 2007
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 use DateTime::Format::Natural;
-use List::Util qw(min max);
+use List::Util 'reduce';
 use parent 'Class::Data::Inheritable';
 
 __PACKAGE__->mk_classdata($_) for qw/scalar_downgrade handlers regex/;
@@ -268,7 +268,7 @@
 
     $self->scalar_downgrade({
         all      => 'first',
-        earliest => 'all_cron',
+        all_cron => 'earliest',
     });
 }
 
@@ -282,10 +282,10 @@
         },
         all      => sub { @_ },
 
-        earliest => sub { min @_ },
-        latest   => sub { max @_ },
-        first    => sub { $_[0] },
-        latest   => sub { $_[-1] },
+        earliest => sub { reduce { $a < $b ? $a : $b } @_ },
+        latest   => sub { reduce { $a > $b ? $a : $b } @_ },
+        first    => sub { $_[0]  },
+        last     => sub { $_[-1] },
     });
 }
 



More information about the Bps-public-commit mailing list