From 5f35084526732b5e41abc2a0d8d4ddb3ca13a34b Mon Sep 17 00:00:00 2001 From: wei <> Date: Wed, 6 Sep 2006 01:08:08 +0000 Subject: Fixed dropdown list for day formatted as 'dd' --- framework/Web/UI/WebControls/TDatePicker.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'framework/Web/UI/WebControls/TDatePicker.php') diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 73a69abc..7654363c 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -600,7 +600,7 @@ class TDatePicker extends TTextBox */ protected function renderCalendarDayOptions($writer, $selected=null) { - $days = array(); for($i=1;$i<=31;$i++) $days[$i] = $i; + $days = $this->getDropDownDayOptions(); $writer->addAttribute('id', $this->getClientID().'_day'); $writer->addAttribute('name', $this->getUniqueID().'$day'); $writer->addAttribute('class', 'datepicker_day_options'); @@ -611,6 +611,22 @@ class TDatePicker extends TTextBox $writer->renderEndTag(); } + /** + * @return array list of day options for a drop down list. + */ + protected function getDropDownDayOptions() + { + $formatter = Prado::createComponent('System.Util.TSimpleDateFormatter', + $this->getDateFormat()); + $days = array(); + $requiresPadding = $formatter->getDayPattern() === 'dd'; + for($i=1;$i<=31;$i++) + { + $days[$i] = $requiresPadding ? str_pad($i, 2, '0', STR_PAD_LEFT) : $i; + } + return $days; + } + /** * Renders the month drop down list options. * @param THtmlWriter the writer used for the rendering purpose @@ -618,7 +634,6 @@ class TDatePicker extends TTextBox */ protected function renderCalendarMonthOptions($writer, $selected=null) { - $info = $this->getLocalizedCalendarInfo(); $writer->addAttribute('id', $this->getClientID().'_month'); $writer->addAttribute('name', $this->getUniqueID().'$month'); -- cgit v1.2.3