[limb-svn] r5839 - in 3.x/trunk/limb/datetime: src tests/cases
svn at limb-project.com
svn at limb-project.com
Tue May 8 20:17:45 MSD 2007
Author: pachanga
Date: 2007-05-08 20:17:44 +0400 (Tue, 08 May 2007)
New Revision: 5839
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5839
Modified:
3.x/trunk/limb/datetime/src/lmbDate.class.php
3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php
Log:
-- lmbDate :: isEqualDate($date) added, it compares dates ignoring time
-- lmbDate :: stripDate() added, it returns new date with time only
-- lmbDate :: stripTime() added, it returns new date without times
Modified: 3.x/trunk/limb/datetime/src/lmbDate.class.php
===================================================================
--- 3.x/trunk/limb/datetime/src/lmbDate.class.php 2007-05-08 14:57:46 UTC (rev 5838)
+++ 3.x/trunk/limb/datetime/src/lmbDate.class.php 2007-05-08 16:17:44 UTC (rev 5839)
@@ -331,6 +331,11 @@
return false;
}
+ function isEqualDate($when)
+ {
+ return $this->stripTime()->isEqual($when->stripTime());
+ }
+
function isLeapYear()
{
return (($this->year % 4 == 0 && $this->year % 100 != 0) || $this->year % 400 == 0);
@@ -564,5 +569,15 @@
$date = new lmbDate(mktime($this->hour, $this->minute, $this->second + $n, $this->month, $this->day, $this->year));
return $date->setTimeZone($this->tz);
}
+
+ function stripTime()
+ {
+ return lmbDate :: createWithoutTime($this->year, $this->month, $this->day, $this->tz);
+ }
+
+ function stripDate()
+ {
+ return new lmbDate($this->hour, $this->minute, $this->second, null, null, null, $this->tz);
+ }
}
?>
\ No newline at end of file
Modified: 3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php
===================================================================
--- 3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php 2007-05-08 14:57:46 UTC (rev 5838)
+++ 3.x/trunk/limb/datetime/tests/cases/lmbDateTest.class.php 2007-05-08 16:17:44 UTC (rev 5839)
@@ -527,5 +527,33 @@
$this->assertEqual($d1->addYear()->compare($d2), 1);
$this->assertEqual($d1->compare($d2->addYear(2)), -1);
}
+
+ function testStripTime()
+ {
+ $date = new lmbDate('2005-01-01 12:20:40');
+ $this->assertEqual($date->stripTime(), new lmbDate('2005-01-01'));
+ }
+
+ function testStripDate()
+ {
+ $date = new lmbDate('2005-01-01 12:20:40');
+ $this->assertEqual($date->stripDate(), new lmbDate('12:20:40'));
+ }
+
+ function testIsDateEqual()
+ {
+ $date1 = new lmbDate('2005-01-01 12:20:40');
+ $date2 = new lmbDate('2005-01-01 13:20:40');
+ $this->assertTrue($date1->isEqualDate($date2));
+ $this->assertTrue($date2->isEqualDate($date1));
+ }
+
+ function testIsDateNotEqual()
+ {
+ $date1 = new lmbDate('2005-02-01 12:20:40');
+ $date2 = new lmbDate('2005-01-01 13:20:40');
+ $this->assertFalse($date1->isEqualDate($date2));
+ $this->assertFalse($date2->isEqualDate($date1));
+ }
}
?>
\ No newline at end of file
More information about the limb-svn
mailing list