本文整理汇总了PHP中DateRange::Dates方法的典型用法代码示例。如果您正苦于以下问题:PHP DateRange::Dates方法的具体用法?PHP DateRange::Dates怎么用?PHP DateRange::Dates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateRange
的用法示例。
在下文中一共展示了DateRange::Dates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDateRangeReturnsAllDatesForRangeWithoutTime
public function testDateRangeReturnsAllDatesForRangeWithoutTime()
{
$begin = Date::Create(2008, 9, 9, 10, 11, 12, 'UTC');
$end = Date::Create(2008, 9, 12, 10, 11, 12, 'UTC');
$range = new DateRange($begin, $end);
$expected[] = $begin->GetDate();
$expected[] = $begin->AddDays(1)->GetDate();
$expected[] = $begin->AddDays(2)->GetDate();
$expected[] = $begin->AddDays(3)->GetDate();
$actual = $range->Dates();
// foreach ($expected as $d)
// {
// echo $d->ToString();
// echo "\n";
// }
//
// echo "\n";
//
// foreach ($actual as $d)
// {
// echo $d->ToString();
// echo "\n";
// }
// $this->assertEquals($expected, $actual);
$this->assertEquals(count($expected), count($actual));
$this->assertTrue($expected[0]->Equals($actual[0]), "Dates[0] are not equal");
$this->assertTrue($expected[1]->Equals($actual[1]), "Dates[1] are not equal");
$this->assertTrue($expected[2]->Equals($actual[2]), "Dates[2] are not equal");
$this->assertTrue($expected[3]->Equals($actual[3]), "Dates[3] are not equal");
}
示例2: __construct
/**
* @param IRestServer $server
* @param int $scheduleId
* @param IDailyLayout $dailyLayout
* @param DateRange $dates
* @param ResourceDto[] $resources
* @param IPrivacyFilter $privacyFilter
*/
public function __construct(IRestServer $server, $scheduleId, IDailyLayout $dailyLayout, DateRange $dates, $resources, IPrivacyFilter $privacyFilter)
{
$this->scheduleId = $scheduleId;
$this->AddService($server, WebServices::GetSchedule, array(WebServiceParams::ScheduleId => $scheduleId));
foreach ($dates->Dates() as $date) {
$scheduleDate = new ScheduleSlotResponse($server, $date);
foreach ($resources as $resource) {
$scheduleResource = new ScheduleSlotResourceResponse($server, $resource, $privacyFilter);
$slots = $dailyLayout->GetLayout($date, $resource->GetId());
foreach ($slots as $slot) {
$scheduleResource->AddSlot($slot);
}
$scheduleDate->AddResource($scheduleResource);
}
$this->dates[] = $scheduleDate;
}
}