You are here

function _archive_validate_date in Archive 7

Same name and namespace in other branches
  1. 6 archive.module \_archive_validate_date()
  2. 7.2 archive.module \_archive_validate_date()

Check if given year, month and date combination is valid for the archive.

Parameters

$year: The year to check.

$month: The month to check.

$day: The day to check.

Return value

TRUE or FALSE.

3 calls to _archive_validate_date()
theme_archive_navigation in ./archive.pages.inc
Theme the archive navigation with years, months and dates by default.
_archive_date in ./archive.module
Parses the current URL and populates an archive date object.
_archive_url in ./archive.module
Generate an archive URL based on the $y, $m and $d provided.

File

./archive.module, line 346
Implements a block and page showing an archive of all site content.

Code

function _archive_validate_date($year, $month = NULL, $day = NULL) {
  $valid = FALSE;
  if ($year && $year <= format_date(time(), 'custom', 'Y')) {
    if (!is_null($month)) {
      if (!is_null($day)) {
        if ($last = gmdate('t', gmmktime(0, 0, 0, $month, 1, $year))) {
          $valid = 0 < $day && $day <= $last;
        }
      }
      elseif (0 < $month && $month <= 12) {
        $valid = TRUE;
      }
    }
    else {
      $valid = TRUE;
    }
  }
  return $valid;
}