Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r19315: LJSUP-8957: Add months and years calenda...

Committer: gariev
LJSUP-8957: Add months and years calendars to all s2 style pages
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-06-17 06:48:45 UTC (rev 19314)
+++ trunk/cgi-bin/LJ/User.pm	2011-06-17 07:50:14 UTC (rev 19315)
@@ -7745,14 +7745,15 @@
         }
     }
     ## $prev_month  = max(  grep { $day < Date($year, $month) }  @$days  );
-    ## max @list    = List::Util::reduce { $a > $b ? $a : $b } @list
+    ## max @list    = List::Util::reduce {  ($a < $b) ? $b : $a } @list
+    ## min @list    = List::Util::reduce { !($a < $b) ? $b : $a } @list
     my $current_month   = [$year, $month];
     my $less_year       = sub { my ($a, $b) = @_; return $a->[0]<$b->[0];  };
     my $less            = sub { my ($a, $b) = @_; return $a->[0]<$b->[0] || $a->[0]==$b->[0] && $a->[1]<$b->[1] };
-    $ret{'prev_month'}  = List::Util::reduce { $less->($a, $b) ? $a : $b }  grep { $less->($_, $current_month) }        @$days;
-    $ret{'next_month'}  = List::Util::reduce { $less->($a, $b) ? $b : $a }  grep { $less->($current_month, $_) }        @$days;
-    $ret{'prev_year'}   = List::Util::reduce { $less->($a, $b) ? $a : $b }  grep { $less_year->($_, $current_month) }   @$days;
-    $ret{'next_year'}   = List::Util::reduce { $less->($a, $b) ? $b : $a }  grep { $less_year->($current_month, $_) }   @$days;
+    $ret{'prev_month'}  = List::Util::reduce {  $less->($a, $b) ? $b : $a } grep { $less->($_, $current_month) }        @$days;
+    $ret{'next_month'}  = List::Util::reduce { !$less->($a, $b) ? $b : $a } grep { $less->($current_month, $_) }        @$days;
+    $ret{'prev_year'}   = List::Util::reduce {  $less->($a, $b) ? $b : $a } grep { $less_year->($_, $current_month) }   @$days;
+    $ret{'next_year'}   = List::Util::reduce { !$less->($a, $b) ? $b : $a } grep { $less_year->($current_month, $_) }   @$days;
     foreach my $k (qw/prev_month next_month prev_year next_year/) {
         if ($ret{$k}) {
             $ret{$k} = [ $ret{$k}->[0]+0, $ret{$k}->[1]+0];

Tags: gariev, livejournal, pm
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments