Change in function.html_select_date.php to allow 2 digit year
[email protected] (Martin Kjeldsen)
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <[email protected]> |
I've changed function.html_select_data.php to allow two digit years instead of
the normal four digit version. The 2 digit version is useful eg. when making
credit card expiration field.
I hope that this is a change worth putting in the cvs tree and that somebody
can put it in. The following is a diff from the origional and the new version
Best regards
Martin Kjeldsen
*** function.html_select_date.php Tue Mar 22 15:42:30 2005
--- function.html_select_date_new.php Tue Mar 22 16:40:22 2005
***************
*** 48,53 ****
--- 48,55 ----
/* Write day values using this format MB */
$day_value_format = "%d";
$year_as_text = false;
+ /* Display years as two digits like 05-99 instead of 2005-2099 */
+ $two_digit_years = false;
/* Display years in reverse order? Ie. 2000,1999,.... */
$reverse_years = false;
/* Should the select boxes be part of an array when returned from PHP?
***************
*** 116,121 ****
--- 118,124 ----
case 'display_years':
case 'year_as_text':
case 'reverse_years':
+ case 'two_digit_years':
$$_key = (bool)$_value;
break;
***************
*** 244,250 ****
}
$year_result .= '>';
} else {
! $years = range((int)$start_year, (int)$end_year);
if ($reverse_years) {
rsort($years, SORT_NUMERIC);
}
--- 247,262 ----
}
$year_result .= '>';
} else {
! if ($two_digit_years) {
! $start_year = substr($start_year, 2);
! $end_year = substr($end_year, 2);
!
! for($i = (int)$start_year; $i < (int)$end_year; $i++)
! $years[] = sprintf('%02d', $i);
! }
! else
! $years = range((int)$start_year, (int)$end_year);
!
if ($reverse_years) {
rsort($years, SORT_NUMERIC);
}