Created
September 29, 2012 11:23
-
-
Save jfsimon/3803729 to your computer and use it in GitHub Desktop.
CalendarUnit use cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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