本文整理匯總了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;
}
}