Wednesday, April 9, 2008

Project Calendar - Taking PHP Further

With the very basic PHP prototype done (of the starting-day offset), I could start working in implementing basic Date Functions to it. Imagine my surprise when I found out that there was a way with PHP Date Functions to get the number of days in a defined month. I quickly coded very simple lines and implemented the daysInMonth variable.

$monthName = mktime(0, 0, 0, definedMonth, 1, definedYear); //gets Month and Year Timestamp for Date()
$daysInMonth = date("t", $monthName);


Here is the resulting Prototype.

With this in place, I don't have to come up with an algorithm to find out the number of days in a certain month. If PHP can do it, I'd be stupid not to use it ;)...

I will have to drop prototyping for a while and start coming up with a pseudocode to find the starting day of a month. As far as I know, PHP doesn't have function that can do it for me. I will have to come up with my own logic for this.

After the algorithm is finished, implementing it is going to be a piece of cake. The prototypes are well done enough to allow easy implementation of an offset, I just need to find out the offset itself and the Month-View Prototype will be complete.