--- onthisday.module 8 Oct 2008 19:51:28 -0000 1.1.2.2.2.4 +++ onthisday.module 24 Dec 2008 21:55:28 -0000 @@ -29,10 +29,27 @@ function _onthisday_list($offset, $month = NULL, $day = NULL) { global $base_url; + // Regardless of the year of publication, start calculating + // the date using the current year. $year = date('Y'); - if (empty($month)) { - $month = date('n'); - $day = date('j'); + // Do we have a node object? + if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) { + // If so, load it. + $node = node_load(arg(1)); + // Set month and day based on the node creation date. + $month = date('n', $node->created); + $day = date('j', $node->created); + } + + // Otherwise, we don't have a node object + // (Why would this be the case? A view? I do not know.) + else { + // If $month is not provided, set $month and $day to the presentday. + // QUESTION: What happens if $month is set but $day is null? + if (empty($month)) { + $month = date('n'); + $day = date('j'); + } } while ($offset > 0) { $year_ago = mktime(0, 0, 0, $month, $day, $year - $offset);