dev-master
9999999-devWIP : A small library for manipulating periods and generate calendars. Still work in progress.
The Requires
by Brendan POIRIER
calendar events day month holidays week
Wallogit.com
2017 © Pedro Peláez
WIP : A small library for manipulating periods and generate calendars. Still work in progress.
WIP : A small library for manipulating periods and generate calendars. Still work in progress., (*1)
You can create a calendar in 2 different ways :, (*2)
By using Laravel facades (requires illuminate\support package), (*3)
$calendar = Calendar::create('2016-09-01', '2017-07-01');, (*4)
Or by instantiating a Calendar class, (*5)
$calendar = new Calendar('2016-09-01', '2017-07-01'), (*6)
You can pass \DateTime() or Moment() instances instead of typing a date format, (*7)
To translate day and month names : MomentLocale::setLocale('fr_FR');, (*8)
Parameter is an integer :, (*9)
Example to set the beginning of a week to Monday, (*10)
$calendar->setWeekFirstDay(1) // 1 for Monday, (*11)
Parameter is an array of integer and system is the same like above : Integers between 0 and 6 match to a specific day., (*12)
$calendar->setNonBusinessDays([0, 3, 6]);, (*13)
You need to create an Event or Holiday object. Both are similar but instantiating an Holiday class will set period as non business period., (*14)
$holiday = new Holiday('Christmas holidays', '2016-12-19', '2017-01-02');
$calendar->addHoliday($holiday);
// same for events, (*15)
You can pass an array or a Calendar\Collections\Collectionof holidays too., (*16)
<html>
<?php foreach($calendar->years() as $year){ ?>
<?php foreach($year->months() as $month) {
echo $month->name();
?>
<table class="calendar">
<thead>
<tr>
<th>Lun</th>
<th>Mar</th>
<th>Mer</th>
<th>Jeu</th>
<th>Ven</th>
<th>Sam</th>
<th>Dim</th>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach($month->days() as $day){
if($day->colspan() != 0){
echo '<td colspan="'.$day->colspan().'"></td>';
}
if(!$day->isBusinessDay()){
echo '<td style="color: #f00">';
}else{
echo '<td>';
}
echo $day.'</td>';
if($day->isWeekLastDay()){
echo '</tr><tr>';
}
}
?>
</tr>
</tbody>
</table>
<?php } ?>
<?php } ?>
</html>
WIP : A small library for manipulating periods and generate calendars. Still work in progress.
calendar events day month holidays week