[limb-svn] r5865 - in 3.x/trunk/limb: datetime/src datetime/tests/cases validation/src/rule
svn at limb-project.com
svn at limb-project.com
Fri May 11 17:05:33 MSD 2007
Author: pachanga
Date: 2007-05-11 17:05:33 +0400 (Fri, 11 May 2007)
New Revision: 5865
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5865
Modified:
3.x/trunk/limb/datetime/src/lmbDate.class.php
3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php
3.x/trunk/limb/validation/src/rule/lmbDateRule.class.php
Log:
-- lmbDate :: isValidDateString() was renamed to validate() and now it's a way more general
Modified: 3.x/trunk/limb/datetime/src/lmbDate.class.php
===================================================================
--- 3.x/trunk/limb/datetime/src/lmbDate.class.php 2007-05-11 12:57:12 UTC (rev 5864)
+++ 3.x/trunk/limb/datetime/src/lmbDate.class.php 2007-05-11 13:05:33 UTC (rev 5865)
@@ -151,11 +151,14 @@
$this->year ? $this->year : 1);
}
- static function isValidDateString($value)
+ static function validate($year_or_date=null, $month_or_tz=null, $day=null, $hour=0, $minute=0, $second=0, $tz='')
{
try
{
- new lmbDate((string)$value);
+ if(func_num_args() > 2)
+ new lmbDate($year_or_date, $month_or_tz, $day, $hour, $minute, $second, $tz);
+ else
+ new lmbDate($year_or_date, $month_or_tz);
return true;
}
catch(lmbException $e)
Modified: 3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php
===================================================================
--- 3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php 2007-05-11 12:57:12 UTC (rev 5864)
+++ 3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php 2007-05-11 13:05:33 UTC (rev 5865)
@@ -44,20 +44,21 @@
catch(lmbException $e){}
}
- function testIsValidDateString()
+ function testValidate()
{
- $this->assertTrue(lmbDate :: isValidDateString('2005-12-01 12:45:12'));
- $this->assertTrue(lmbDate :: isValidDateString('2005-12-01 12:45'));
- $this->assertTrue(lmbDate :: isValidDateString('2005-12-01'));
- $this->assertTrue(lmbDate :: isValidDateString('12:45:12'));
- $this->assertTrue(lmbDate :: isValidDateString('12:45'));
- $this->assertTrue(lmbDate :: isValidDateString(' 12:45:12 '));
+ $this->assertTrue(lmbDate :: validate('2005-12-01 12:45:12'));
+ $this->assertTrue(lmbDate :: validate('2005-12-01 12:45'));
+ $this->assertTrue(lmbDate :: validate('2005-12-01'));
+ $this->assertTrue(lmbDate :: validate('12:45:12'));
+ $this->assertTrue(lmbDate :: validate('12:45'));
+ $this->assertTrue(lmbDate :: validate(' 12:45:12 '));
}
- function testIsValidDateStringFalse()
+ function testValidateFalse()
{
- $this->assertFalse(lmbDate :: isValidDateString('baba-duba'));
- $this->assertFalse(lmbDate :: isValidDateString('2005-12-01 12.'));
+ $this->assertFalse(lmbDate :: validate('baba-duba'));
+ $this->assertFalse(lmbDate :: validate('2005-12-01 12.'));
+ $this->assertFalse(lmbDate :: validate(2006, 13, 11));
}
function testCreate()
Modified: 3.x/trunk/limb/validation/src/rule/lmbDateRule.class.php
===================================================================
--- 3.x/trunk/limb/validation/src/rule/lmbDateRule.class.php 2007-05-11 12:57:12 UTC (rev 5864)
+++ 3.x/trunk/limb/validation/src/rule/lmbDateRule.class.php 2007-05-11 13:05:33 UTC (rev 5865)
@@ -32,7 +32,7 @@
{
if($this->type == lmbDateRule :: TYPE_ISO)
{
- if(!lmbDate :: isValidDateString($value))
+ if(!lmbDate :: validate((string)$value))
$this->error('{Field} is not a valid ISO formatted date(YYYY-MM-DD HH:MM).');
}
}
More information about the limb-svn
mailing list