add day_value_format to html_select_date

This commit is contained in:
mohrt
2002-12-13 15:40:53 +00:00
parent 27f8e2c40b
commit 1f12a0f3e0
4 changed files with 26 additions and 5 deletions

2
NEWS
View File

@@ -1,3 +1,5 @@
- added day_value_format to html_select_date (Marcus
Bointon, Monte)
- assigned variables are not longer in global - assigned variables are not longer in global
namespace, saving extract() calls and speeding namespace, saving extract() calls and speeding
up fetch() and display() linearly with no. of up fetch() and display() linearly with no. of

View File

@@ -3494,7 +3494,14 @@ OUTPUT:
<entry>string</entry> <entry>string</entry>
<entry>No</entry> <entry>No</entry>
<entry>%02d</entry> <entry>%02d</entry>
<entry>what format the day should be in (sprintf)</entry> <entry>what format the day output should be in (sprintf)</entry>
</row>
<row>
<entry>day_value_format</entry>
<entry>string</entry>
<entry>No</entry>
<entry>%d</entry>
<entry>what format the day value should be in (sprintf)</entry>
</row> </row>
<row> <row>
<entry>year_as_text</entry> <entry>year_as_text</entry>

View File

@@ -15,6 +15,8 @@
* time value. (Jan Rosier) * time value. (Jan Rosier)
* 1.3 added support for choosing format for * 1.3 added support for choosing format for
* month values (Gary Loescher) * month values (Gary Loescher)
* 1.3.1 added support for choosing format for
* day values (Marcus Bointon)
* ------------------------------------------------------------- * -------------------------------------------------------------
*/ */
require_once $this->_get_plugin_filepath('shared','make_timestamp'); require_once $this->_get_plugin_filepath('shared','make_timestamp');
@@ -32,6 +34,8 @@ function smarty_function_html_select_date($params, &$smarty)
/* Write months as numbers by default GL */ /* Write months as numbers by default GL */
$month_value_format = "%m"; $month_value_format = "%m";
$day_format = "%02d"; $day_format = "%02d";
/* Write day values using this format MB */
$day_value_format = "%d";
$year_as_text = false; $year_as_text = false;
/* Display years in reverse order? Ie. 2000,1999,.... */ /* Display years in reverse order? Ie. 2000,1999,.... */
$reverse_years = false; $reverse_years = false;
@@ -128,8 +132,10 @@ function smarty_function_html_select_date($params, &$smarty)
if ($display_days) { if ($display_days) {
$days = array(); $days = array();
for ($i = 1; $i <= 31; $i++) for ($i = 1; $i <= 31; $i++) {
$days[] = sprintf($day_format, $i); $days[] = sprintf($day_format, $i);
$day_values[] = sprintf($day_value_format, $i);
}
$day_result .= '<select name='; $day_result .= '<select name=';
if (null !== $field_array){ if (null !== $field_array){
@@ -148,7 +154,7 @@ function smarty_function_html_select_date($params, &$smarty)
} }
$day_result .= '>'."\n"; $day_result .= '>'."\n";
$day_result .= smarty_function_html_options(array('output' => $days, $day_result .= smarty_function_html_options(array('output' => $days,
'values' => range(1, 31), 'values' => $day_values,
'selected' => $time[2], 'selected' => $time[2],
'print_result' => false), 'print_result' => false),
$smarty); $smarty);

View File

@@ -15,6 +15,8 @@
* time value. (Jan Rosier) * time value. (Jan Rosier)
* 1.3 added support for choosing format for * 1.3 added support for choosing format for
* month values (Gary Loescher) * month values (Gary Loescher)
* 1.3.1 added support for choosing format for
* day values (Marcus Bointon)
* ------------------------------------------------------------- * -------------------------------------------------------------
*/ */
require_once $this->_get_plugin_filepath('shared','make_timestamp'); require_once $this->_get_plugin_filepath('shared','make_timestamp');
@@ -32,6 +34,8 @@ function smarty_function_html_select_date($params, &$smarty)
/* Write months as numbers by default GL */ /* Write months as numbers by default GL */
$month_value_format = "%m"; $month_value_format = "%m";
$day_format = "%02d"; $day_format = "%02d";
/* Write day values using this format MB */
$day_value_format = "%d";
$year_as_text = false; $year_as_text = false;
/* Display years in reverse order? Ie. 2000,1999,.... */ /* Display years in reverse order? Ie. 2000,1999,.... */
$reverse_years = false; $reverse_years = false;
@@ -128,8 +132,10 @@ function smarty_function_html_select_date($params, &$smarty)
if ($display_days) { if ($display_days) {
$days = array(); $days = array();
for ($i = 1; $i <= 31; $i++) for ($i = 1; $i <= 31; $i++) {
$days[] = sprintf($day_format, $i); $days[] = sprintf($day_format, $i);
$day_values[] = sprintf($day_value_format, $i);
}
$day_result .= '<select name='; $day_result .= '<select name=';
if (null !== $field_array){ if (null !== $field_array){
@@ -148,7 +154,7 @@ function smarty_function_html_select_date($params, &$smarty)
} }
$day_result .= '>'."\n"; $day_result .= '>'."\n";
$day_result .= smarty_function_html_options(array('output' => $days, $day_result .= smarty_function_html_options(array('output' => $days,
'values' => range(1, 31), 'values' => $day_values,
'selected' => $time[2], 'selected' => $time[2],
'print_result' => false), 'print_result' => false),
$smarty); $smarty);