/** * Default test. A 6 months calendar with the entire structure, including: * Quarters, weeks... */ public function testDefault() { $cal = new \SSC\Calendar(); $structure = $cal->getCalendarStructure(); $this->assertArrayHasKey(date('Y'), $structure); $quarter = (int) ceil(date('n') / 3); $this->assertArrayHasKey($quarter, $structure[date('Y')]['elements']); $this->assertArrayHasKey(date('n'), $structure[date('Y')]['elements'][$quarter]['elements']); }
<?php /** * To execute this example you need to install the library with composer in order * to use the autoload in this include file. * If you dont wanna use composer just include each file from the src directory. */ //include 'calendar/src/SSC/Calendar.php'; //include 'calendar/src/SSC/CalendarConfig.php'; //include 'calendar/src/SSC/formatters/FormatterInterface.php'; //include 'calendar/src/SSC/formatters/ArrayFormatter.php'; //include 'calendar/src/SSC/formatters/ObjectFormatter.php'; //include 'calendar/src/SSC/formatters/JsonFormatter.php'; include '../vendor/autoload.php'; $cal = new \SSC\Calendar(); $cal->day_callback = function ($date) { $day = new stdClass(); $day->has_passed = $date->getTimestamp() < time(); return $day; }; $structure = $cal->getCalendarStructure(); ?> <h1>Spanish calendar</h1> <?php foreach ($structure as $year) { ?> <?php foreach ($year['elements'] as $quarter) { ?> <?php