+ return "\n<div><div class=\"calendar\">$calendar</div></div>\n";
+} #}}
+
+sub needsbuild (@) { #{{{
+ my $needsbuild=shift;
+ foreach my $page (keys %pagestate) {
+ if (exists $pagestate{$page}{calendar}{nextchange}) {
+ if ($pagestate{$page}{calendar}{nextchange} <= $time) {
+ # force a rebuild so the calendar shows
+ # the current day
+ push @$needsbuild, $pagesources{$page};
+ }
+ if (exists $pagesources{$page} &&
+ grep { $_ eq $pagesources{$page} } @$needsbuild) {
+ # remove state, will be re-added if
+ # the calendar is still there during the
+ # rebuild
+ delete $pagestate{$page}{calendar};
+ }
+ }
+ }
+} # }}}