public function testGetViewData() { $c = new Calendar(new DateTime('2014-05-27')); $c->setResolution(new MonthResolution()); $viewData = $c->viewData(); $this->assertArrayHasKey('contents', $viewData); $this->assertTrue(is_array($viewData['contents'])); }
<?php require_once __DIR__ . '/../vendor/autoload.php'; use Solution10\Calendar\Calendar; use Solution10\Calendar\Resolution\MonthResolution; // Set up the calendar: $calendar = new Calendar(new DateTime('2014-05-02')); // Now you need to give it a "resolution". This tells the calendar how to display itself. // In this case, we want to show a "month" view: $calendar->setResolution(new MonthResolution()); $viewData = $calendar->viewData(); /* @var $months Solution10\Calendar\Month[] */ $months = $viewData['contents']; // That's it! Let's render the calendar: ?> <h2>Just May</h2> <?php foreach ($months as $month) { ?> <table style="float: left; width: 25%; margin: 0 1%;"> <caption><?php echo $month->title('F Y'); ?> </caption> <thead> <tr> <?php foreach ($month->weeks()[0]->days() as $day) { ?> <th><?php echo $day->date()->format('D');
<?php require_once __DIR__ . '/../vendor/autoload.php'; use Solution10\Calendar\Calendar; use Solution10\Calendar\Resolution\WeekResolution; // Set up the calendar: $calendar = new Calendar(new DateTime('2014-05-02')); // Now you need to give it a "resolution". This tells the calendar how to display itself. // In this case, we want to show a "week" view: $calendar->setResolution(new WeekResolution()); $viewData = $calendar->viewData(); /* @var $week Solution10\Calendar\Week */ $week = $viewData['contents']; // That's it! Let's render the calendar: ?> <h2>Week</h2> <table> <caption> <?php echo $week->weekStart()->format('j F'); ?> - <?php echo $week->weekEnd()->format('j F'); ?> </caption> <thead> <tr> <?php foreach ($week->days() as $day) {