You are here

function date_range_string in Date 6.2

Same name and namespace in other branches
  1. 8 date_api/date_api.module \date_range_string()
  2. 7.3 date_api/date_api.module \date_range_string()
  3. 7 date_api/date_api.module \date_range_string()
  4. 7.2 date_api/date_api.module \date_range_string()

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

Parameters

unknown_type $years:

Return value

unknown

1 call to date_range_string()
date_popup_process_date in date_popup/date_popup.module
Process the date portion of the element.

File

./date_api.module, line 2636
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

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;
}