Monday, September 22, 2008

CSI: Miami Season 7 Premiere

On right now on CTV

Insane episode... 10pm Eastern on CBS for the rest of you guys (about 2.5 hours).

Regular blogging will start again soon... promise!

October 9th EDIT: I just realized I put Season '9' instead of '7'... fixed!

Friday, September 5, 2008

What are you Playing this Weekend?

Wow, I haven't done this for a while!

It's my birthday weekend. Going to spend it back home with my parents. Bringing my PSP with me. I'm going to concentrate on a few games...
  • Disgaea: Afternoon of Darkness
  • Patapon
  • N+
So, like ol' times sake:

What are YOU playing this weekend?

Wednesday, September 3, 2008

Project Calendar - Month-View Generator

Here is the code of the function that generates the calendar, passing two variables (static or user generated).

function renderCalendar($strMonth, $strYear) {
$date = mktime(12, 0, 0, $strMonth, 1, $strYear);
$daysInMonth = date("t", $date);
$dayOffset = date("w", $date);

$calendarWeeks = ceil(($daysInMonth + $dayOffset) / 7) - 1; //how many weeks (rows) in the month

echo "*****HTML Code for Table *****";

for ($rowIndex = 0; $rowIndex <= $calendarWeeks; $rowIndex++) {
echo "*****HTML Code for Table Row *****";
for ($colIndex = 1; $colIndex <= 7; $colIndex++) {
$currentDay = ($colIndex - $dayOffset) + ($rowIndex * 7);

if ($currentDay < 1 or $currentDay > $daysInMonth) {
echo "*****HTML Code for empty cell *****";
} else {
echo "*****HTML Code for date cell *****";
}
}
echo "*****HTML Code for closing Table Row *****";
}
}


You can check the result here.

Project Calendar - First day of the month...

For quite a while, I have been doing some research on simple algorithms to find out what was the first day of the month, defining the offset. But then it hit me: "What if I just generate my date variable at the first of the current month?"...

Yes, that's all I had to do. Use mkdate(); using the current month and year (or user selected month and year) and make my date variable with the first day of the month. I can check the day of the week of any date variable with PHP...

...Simple!

I now have a working calendar that, by default, shows the current month. Users can then select a month and year (within certain ranges) and the calendar will change, with the correct number of days and the right starting day.

I'm cleaning up the code a little bit. I will upload it later and post the renderCalendar() function.

Tuesday, September 2, 2008

Project Calendar - In Goes Functions!

This is not an elaborate post on complex algorithm I just found out, no. This is just an update saying that I'm starting to put functions in my PHP code. For the sake of prototyping, I was putting my code directly in the Body (the linear way), but it's time to clean up before I start working on the offset (first day of the month) algorithm.