diff options
author | xue <> | 2006-04-25 01:31:43 +0000 |
---|---|---|
committer | xue <> | 2006-04-25 01:31:43 +0000 |
commit | 5ba6cd4be568f686d890835a77586077cde1a943 (patch) | |
tree | 54138a79e147bcfb0f6833d2d284a2f825c18f2a /framework/Web/UI/WebControls/TDatePicker.php | |
parent | 1afc913c386bba8e6072c278b0eb4fd9818ab310 (diff) |
Merge from 3.0 branch till 967.
Diffstat (limited to 'framework/Web/UI/WebControls/TDatePicker.php')
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index c6a2345b..02386515 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -245,17 +245,16 @@ class TDatePicker extends TTextBox /**
* @return integer current selected date from the date picker as timestamp.
*/
- public function getDate()
+ public function getTimeStamp()
{
- $date = $this->getDateFromText();
- return $date[0];
+ return $this->getTimeStampFromText();
}
/**
* Sets the date for the date picker using timestamp.
* @param integer time stamp for the date picker
*/
- public function setDate($value)
+ public function setTimeStamp($value)
{
$date = TPropertyValue::ensureInteger($value);
$formatter = Prado::createComponent('System.Util.TSimpleDateFormatter',
@@ -264,6 +263,34 @@ class TDatePicker extends TTextBox }
/**
+ * @return string the date string.
+ */
+ public function getDate()
+ {
+ return $this->getText();
+ }
+
+ /**
+ * @param string date string
+ */
+ public function setDate($value)
+ {
+ $this->setText($value);
+ }
+
+ /**
+ * Returns the value to be validated.
+ * This methid is required by IValidatable interface.
+ * @return integer the value of the property to be validated.
+ */
+ public function getValidationPropertyValue()
+ {
+ if($this->getText() === '')
+ return '';
+ return $this->getTimeStamp();
+ }
+
+ /**
* Publish the date picker Css asset files.
*/
public function onPreRender($param)
@@ -396,6 +423,7 @@ class TDatePicker extends TTextBox $date = $this->getLocalizedCalendarInfo();
$options['MonthNames'] = TJavaScript::encode($date->getMonthNames(),false);
+ $options['AbbreviatedMonthNames'] = TJavaScript::encode($date->getAbbreviatedMonthNames(),false);
$options['ShortWeekDayNames'] = TJavaScript::encode($date->getAbbreviatedDayNames(),false);
return $options;
@@ -439,7 +467,8 @@ class TDatePicker extends TTextBox $writer->addAttribute('class', $class);
$writer->renderBeginTag('span');
- $date = $this->getDateFromText();
+ $date = @getdate($this->getTimeStampFromText());
+
$this->renderCalendarSelections($writer, $date);
//render a hidden input field
@@ -481,9 +510,9 @@ class TDatePicker extends TTextBox /**
* Gets the date from the text input using TSimpleDateFormatter
- * @return array current selected date
+ * @return integer current selected date timestamp
*/
- protected function getDateFromText()
+ protected function getTimeStampFromText()
{
$pattern = $this->getDateFormat();
$pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern);
@@ -559,7 +588,7 @@ class TDatePicker extends TTextBox case 'MMM':
case 'MM': return $info->getAbbreviatedMonthNames();
case 'M':
- $array = array(); for($i=1;$i<=12;$i++) $array[$i] = $i;
+ $array = array(); for($i=1;$i<=12;$i++) $array[$i-1] = $i;
return $array;
default : return $info->getMonthNames();
}
|