#native_company# #native_desc#
#native_cta#

Easy Calendar Applications Page 3

By Mark Musone
on July 30, 2000

The other function we will use is:

<?php mcal_days_in_month($month,$leap_year); ?>

This simply returns the number of days in a given month, taking into account if it is a leap year or not.
To find out what day of the week the first of the month is, because we need to display
the first on the correct weekday when we go to display the calendar, we use:

<?php $startday=mcal_day_of_week($year,$month,1); ?>

The next function is where the majority of the work is done:

<?php $events=mcal_list_events($stream,$year,$month,1,$year,$month,$days); ?>

This function takes in a stream, and beginning and end dates. It returns a list of
event ID’s for every event that is scheduled between the two dates.
Once we have this list of ID’s, we need to loop through the events and find their actual dates.
while we are at it, we might as well store the title of the events since we will be
printing them out in the month view also:

<?php

for($x=0$x<count($events); $x++) {

    
$event=mcal_fetch_event($stream,$events[$x]);

    
$start=$event->start;

    
$date_array[$start->mday]=$date_array[$start->mday] . "<br>$event->title";

}

?>

Now that we have all the date and event information, the rest is simple. We just
loop through all the dates, printing out the information we need.