From ed23f90c4ed5e9fbbebfb132c4e4b993b30e8daf Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Wed, 8 Sep 2004 23:37:47 +0000 Subject: [PATCH] (Cal): Highlight current day in the yearly calendar as well. No longer accept $mday as a parameter. (PrintYearCalendar): No longer pass $mday parameter. --- modules/calendar.pl | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/calendar.pl b/modules/calendar.pl index c93c3997..9a596816 100644 --- a/modules/calendar.pl +++ b/modules/calendar.pl @@ -16,7 +16,7 @@ # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA -$ModulesDescription .= '

$Id: calendar.pl,v 1.23 2004/09/04 09:41:00 as Exp $

'; +$ModulesDescription .= '

$Id: calendar.pl,v 1.24 2004/09/08 23:37:47 as Exp $

'; use vars qw($CalendarOnEveryPage $CalendarUseCal); @@ -44,13 +44,12 @@ sub NewCalendarGetHeader { } sub Cal { - my ($year, $mon, $mday, $unlink_year) = @_; # example: 2004, 12. - if (not $mon) { - my ($sec, $min, $hour); - ($sec, $min, $hour, $mday, $mon, $year) = localtime($Now); - $mon += 1; - $year += 1900; - } + my ($year, $mon, $unlink_year) = @_; # example: 2004, 12 + my ($sec_now, $min_now, $hour_now, $mday_now, $mon_now, $year_now) = localtime($Now); + $mon_now += 1; + $year_now += 1900; + $year = $year_now unless $year; + $mon = $mon_now unless $mon; my @pages = AllPagesList(); my $cal = ''; if ($CalendarUseCal) { @@ -63,11 +62,11 @@ sub Cal { return T('Missing one of cal(1), Date::Calc(3), or Date::Pcalc(3) to produce the calendar.') unless $cal; $cal =~ s|\b([A-Z][a-z])\b|{ T($1); }|ge; - $cal =~ s|\b( ?\d?\d)\b|{ + $cal =~ s|\b( ?[ 0-9]?[0-9])\b|{ my $day = $1; my $date = sprintf("%d-%02d-%02d", $year, $mon, $day); - my $class; - $class = ' today' if $day == $mday; + my $class = ''; + $class .= ' today' if $day == $mday_now and $mon == $mon_now and $year == $year_now; my @matches = grep(/^$date/, @pages); my $link; if (@matches == 0) { # not using GetEditLink because of $class @@ -158,7 +157,7 @@ sub PrintYearCalendar { ' | ', ScriptLink('action=calendar;year=' . ($year+1), T('Next'))); for $mon ((1..12)) { - print Cal($year, $mon, undef, 1); + print Cal($year, $mon, 1); } print ''; }