1 date.inc date_range_string($years)

Converts a min and max year into a string like '-3:+1'.

Parameters

array $years: A numerically indexed array, containing a minimum and maximum year.

Return value

string: A min and max year string like '-3:+1'.

File

core/includes/date.inc, line 1494
Date API functions.

Code

function date_range_string($years) {
  $this_year = date_format(date_now(), 'Y');

  if ($years[0] < $this_year) {
    $min = '-' . ($this_year - $years[0]);
  }
  else {
    $min = '+' . ($years[0] - $this_year);
  }

  if ($years[1] < $this_year) {
    $max = '-' . ($this_year - $years[1]);
  }
  else {
    $max = '+' . ($years[1] - $this_year);
  }

  return $min . ':' . $max;
}