function date_range_string in Date 7.3
Same name and namespace in other branches
- 8 date_api/date_api.module \date_range_string()
- 6.2 date_api.module \date_range_string()
- 7 date_api/date_api.module \date_range_string()
- 7.2 date_api/date_api.module \date_range_string()
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'.
1 call to date_range_string()
- date_popup_process_date_part in date_popup/
date_popup.module - Process the date portion of the element.
File
- date_api/
date_api.module, line 2814 - This module will make the date API available to other modules.
Code
function date_range_string(array $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;
}