From 5235271e1871d5cbedc852c5508c540a7143fc8d Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 4 Mar 2007 02:15:03 +0000 Subject: Fixed #549. --- framework/Web/UI/WebControls/TDatePicker.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'framework') diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 1d7f780b..ca52523d 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -260,11 +260,14 @@ class TDatePicker extends TTextBox } /** - * @return integer current selected date from the date picker as timestamp. + * @return integer current selected date from the date picker as timestamp, NULL if timestamp is not set previously. */ public function getTimeStamp() { - return $this->getTimeStampFromText(); + if(trim($this->getText())==='') + return null; + else + return $this->getTimeStampFromText(); } /** @@ -273,11 +276,14 @@ class TDatePicker extends TTextBox */ public function setTimeStamp($value) { - $date = TPropertyValue::ensureFloat($value); - $formatter = Prado::createComponent('System.Util.TSimpleDateFormatter', - $this->getDateFormat()); - $d =$formatter->format($date); - $this->setText($d); + if($value===null || (is_string($value) && trim($value)==='') + $this->setText(''); + else + { + $date = TPropertyValue::ensureFloat($value); + $formatter = Prado::createComponent('System.Util.TSimpleDateFormatter',$this->getDateFormat()); + $this->setText($formatter->format($date)); + } } /** -- cgit v1.2.3