本文整理匯總了PHP中DateRange::Contains方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateRange::Contains方法的具體用法?PHP DateRange::Contains怎麽用?PHP DateRange::Contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DateRange
的用法示例。
在下文中一共展示了DateRange::Contains方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Overlaps
/**
* Whether or not the date ranges overlap. Dates that start or end on boundaries are excluded
* @param DateRange $dateRange
* @return bool
*/
public function Overlaps(DateRange $dateRange)
{
return ($this->Contains($dateRange->GetBegin()) || $this->Contains($dateRange->GetEnd()) || $dateRange->Contains($this->GetBegin()) || $dateRange->Contains($this->GetEnd())) && (!$this->GetBegin()->Equals($dateRange->GetEnd()) && !$this->GetEnd()->Equals($dateRange->GetBegin()));
}
示例2: testDateIsWithinRange
public function testDateIsWithinRange()
{
$begin = Date::Create(2008, 9, 9, 10, 11, 12, 'UTC');
$end = Date::Create(2008, 10, 9, 10, 11, 12, 'UTC');
$range = new DateRange($begin, $end);
$within = $begin->AddDays(10);
$notWithin = $begin->AddDays(-10);
$exactStart = $begin;
$exactEnd = $end;
$this->assertTrue($range->Contains($within));
$this->assertTrue($range->Contains($exactStart));
$this->assertTrue($range->Contains($exactEnd));
$this->assertFalse($range->Contains($notWithin));
}