- my $pagespec = $params{pages};
- my $year = $params{year};
- my $month = $params{month};
- my $pmonth = $params{pmonth};
- my $nmonth = $params{nmonth};
- my $pyear = $params{pyear};
- my $nyear = $params{nyear};
+ my %linkcache;
+ foreach my $p (pagespec_match_list($params{page},
+ "creation_year($params{year}) and creation_month($params{month}) and ($params{pages})",
+ # add presence dependencies to update
+ # month calendar when pages are added/removed
+ deptype => deptype("presence"))) {
+ my $mtime = $IkiWiki::pagectime{$p};
+ my @date = localtime($mtime);
+ my $mday = $date[3];
+ my $month = $date[4] + 1;
+ my $year = $date[5] + 1900;
+ my $mtag = sprintf("%02d", $month);
+
+ # Only one posting per day is being linked to.
+ $linkcache{"$year/$mtag/$mday"} = $p;
+ }
+
+ my $pmonth = $params{month} - 1;
+ my $nmonth = $params{month} + 1;
+ my $pyear = $params{year};
+ my $nyear = $params{year};
+
+ # Adjust for January and December
+ if ($params{month} == 1) {
+ $pmonth = 12;
+ $pyear--;
+ }
+ if ($params{month} == 12) {
+ $nmonth = 1;
+ $nyear++;
+ }
+
+ # Add padding.
+ $pmonth=sprintf("%02d", $pmonth);
+ $nmonth=sprintf("%02d", $nmonth);