summaryrefslogtreecommitdiff
path: root/framework/Data
diff options
context:
space:
mode:
authorwei <>2006-02-18 23:41:16 +0000
committerwei <>2006-02-18 23:41:16 +0000
commit270282e3a26b21184a2051995cb5b9a2755b823d (patch)
tree761d82ad761996f329d63acc770fc5a0bce9d5a2 /framework/Data
parentf1cc3c880b564362e7f00b18326e116884879231 (diff)
Update some javascript code.
Diffstat (limited to 'framework/Data')
-rw-r--r--framework/Data/TSimpleDateFormatter.php (renamed from framework/Data/TDateTimeSimpleFormatter.php)28
1 files changed, 17 insertions, 11 deletions
diff --git a/framework/Data/TDateTimeSimpleFormatter.php b/framework/Data/TSimpleDateFormatter.php
index ac5fb685..d2f78b37 100644
--- a/framework/Data/TDateTimeSimpleFormatter.php
+++ b/framework/Data/TSimpleDateFormatter.php
@@ -1,6 +1,6 @@
<?php
/**
- * TDateTimeSimpleFormatter class file
+ * TSimpleDateFormatter class file
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
@@ -11,7 +11,7 @@
*/
/**
- * TDateTimeSimpleFormatter class.
+ * TSimpleDateFormatter class.
*
* Formats and parses dates using the SimpleDateFormat pattern.
* This pattern is compatible with the I18N and java's SimpleDateFormatter.
@@ -29,13 +29,13 @@
*
* Usage example, to format a date
* <code>
- * $formatter = new TDateTimeSimpleFormatter("dd/MM/yyy");
+ * $formatter = new TSimpleDateFormatter("dd/MM/yyy");
* echo $formatter->format(time());
* </code>
*
* To parse the date string into a date timestamp.
* <code>
- * $formatter = new TDateTimeSimpleFormatter("d-M-yyy");
+ * $formatter = new TSimpleDateFormatter("d-M-yyy");
* echo $formatter->parse("24-6-2005");
* </code>
*
@@ -44,7 +44,7 @@
* @package System.Data
* @since 3.0
*/
-class TDateTimeSimpleFormatter
+class TSimpleDateFormatter
{
/**
* Formatting pattern.
@@ -129,11 +129,11 @@ class TDateTimeSimpleFormatter
private function getDate($value)
{
if(is_int($value))
- return getdate($value);
+ return @getdate($value);
$date = @strtotime($value);
if($date < 0)
throw new TInvalidDataValueException('invalid_date', $value);
- return getdate($date);
+ return @getdate($date);
}
/**
@@ -150,12 +150,18 @@ class TDateTimeSimpleFormatter
* @return int date time stamp
* @throws TInvalidDataValueException if date string is malformed.
*/
- public function parse($value,$defaulToCurrentTime=true)
+ public function parse($value,$defaultToCurrentTime=true)
{
if(!is_string($value))
throw new TInvalidDataValueException('date_to_parse_must_be_string', $value);
+
if(empty($this->pattern)) return time();
+ $date = $this->getDate(time());
+
+ if($this->length(trim($value)) < 1)
+ return $defaultToCurrentTime ? $date : null;
+
$pattern = $this->pattern;
$i_val = 0;
@@ -165,8 +171,8 @@ class TDateTimeSimpleFormatter
$token='';
$x=null; $y=null;
- $date = $this->getDate(time());
- if($defaulToCurrentTime)
+
+ if($defaultToCurrentTime)
{
$year = "{$date['year']}";
$month = $date['mon'];
@@ -242,7 +248,7 @@ class TDateTimeSimpleFormatter
if(!$defaultToCurrentTime && (is_null($month) || is_null($day) || is_null($year)))
return null;
else
- return mktime(0, 0, 0, $month, $day, $year);
+ return $this->getDate(@mktime(0, 0, 0, $month, $day, $year));
}
/**