Skip to content

Instantly share code, notes, and snippets.

@jfsimon
Created September 29, 2012 11:23
Show Gist options
  • Save jfsimon/3803729 to your computer and use it in GitHub Desktop.
Save jfsimon/3803729 to your computer and use it in GitHub Desktop.
CalendarUnit use cases
/**
* Je veux afficher les semaines et leur nombre d'évènements
* associés groupées par mois pour l'année 2011.
*/
$year = new CalendarUnit($calendar, new TimeUnitInterval(TimeUnitFactory::year(), 2011));
foreach ($year->getChildren(TimeUnitFactory::month()) as $month) {
echo 'Mois n°'.($month->getIndex() + 1)."\n";
if (count($month) > 0) {
foreach ($month->getChildren(TimeUnitFactory::week()) as $week) {
echo 'Semaine n°'.($week->getIndex() + 1).' : '.count($week)."\n";
}
} else {
echo 'Aucun évènement.'."\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment