本文整理汇总了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));
}