summaryrefslogtreecommitdiff
path: root/framework/Util/TSimpleDateFormatter.php
diff options
context:
space:
mode:
authorwei <>2006-04-25 01:00:08 +0000
committerwei <>2006-04-25 01:00:08 +0000
commitc84f3e19b54cf54f525f4b2d158696ae32d1bf60 (patch)
tree60720fba29ef72175db47dd3cd4b74d8bbed605b /framework/Util/TSimpleDateFormatter.php
parent09edc6590523e26fffbf32f7b0e7958c166f7537 (diff)
Add TListControlValidator. Update client-side validators, datepicker.js, colorpicker.js.
Diffstat (limited to 'framework/Util/TSimpleDateFormatter.php')
-rw-r--r--framework/Util/TSimpleDateFormatter.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/framework/Util/TSimpleDateFormatter.php b/framework/Util/TSimpleDateFormatter.php
index 7be49bc9..2a3da63a 100644
--- a/framework/Util/TSimpleDateFormatter.php
+++ b/framework/Util/TSimpleDateFormatter.php
@@ -190,18 +190,20 @@ class TSimpleDateFormatter
/**
* Parse the string according to the pattern.
- * @param string date string to parse
+ * @param string|int date string or integer to parse
* @return int date time stamp
* @throws TInvalidDataValueException if date string is malformed.
*/
public function parse($value,$defaultToCurrentTime=true)
{
- if(!is_string($value))
+ if(is_int($value))
+ return $value;
+ else if(!is_string($value))
throw new TInvalidDataValueException('date_to_parse_must_be_string', $value);
if(empty($this->pattern)) return time();
- $date = $this->getDate(time());
+ $date = time();
if($this->length(trim($value)) < 1)
return $defaultToCurrentTime ? $date : null;
@@ -246,7 +248,8 @@ class TSimpleDateFormatter
if ($token=='y') { $x=2;$y=4; }
$year = $this->getInteger($value,$i_val,$x,$y);
if(is_null($year))
- throw new TInvalidDataValueException('Invalid year', $value);
+ return null;
+ //throw new TInvalidDataValueException('Invalid year', $value);
$i_val += strlen($year);
if(strlen($year) == 2)
{
@@ -264,7 +267,8 @@ class TSimpleDateFormatter
$this->length($token),2);
$iMonth = intval($month);
if(is_null($month) || $iMonth < 1 || $iMonth > 12 )
- throw new TInvalidDataValueException('Invalid month', $value);
+ return null;
+ //throw new TInvalidDataValueException('Invalid month', $value);
$i_val += strlen($month);
$month = $iMonth;
}
@@ -274,14 +278,16 @@ class TSimpleDateFormatter
$this->length($token), 2);
$iDay = intval($day);
if(is_null($day) || $iDay < 1 || $iDay >31)
- throw new TInvalidDataValueException('Invalid day', $value);
+ return null;
+ //throw new TInvalidDataValueException('Invalid day', $value);
$i_val += strlen($day);
$day = $iDay;
}
else
{
if($this->substring($value, $i_val, $this->length($token)) != $token)
- throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value);
+ return null;
+ //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value);
else
$i_val += $this->length($token);
}