Re: Call for Votes: PEAR::Calendar

From: Date: Sat, 25 Oct 2003 10:17:19 +0000
Subject: Re: Call for Votes: PEAR::Calendar
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22984@lists.php.net to get a copy of this message
On Sat, 25 Oct 2003 01:41:41 +0200, Lorenzo Alberton wrote: > However, here's a list of changes I'd like to see: > > 1) last*() should be called prev*(). > I think they can be misleading. E.g., lastDay() suggests me "the > last day of the year", not "the day before the current one". > prevDay() is easier to understand, IMO. > > 2) use PEAR::Date as backend > > 3) follow a directory structure as every PEAR pkg does: > Calendar_Engine_Factory.php should be Calendar/Engine/Factory.php > and follow CS like using "require_once" > > 4) I like Alan's proposal of handling dates this way: > >> $nextday = $date->make($date->year, $date->month, $date+1); >> $nextmonth = $date->make($date->year, $date->month+1, $date); Another thing I *really* think should be improved: 5) week management. As far as I can see, the current implementation is only focused on tabular data. What if I want a full week, even if it's across two months, or i want to get the prev/next *full* week no matter the month it is in? The easiest solution I see for this issue is dropping the Calendar_Day_Empty class and adding a "empty" property to the Calendar_Day class. The "empty" flag should be set according to the position of the day wrt the current month, i.e. if the day is not a day of the current month, the $day->empty should be set to true, but all the other fields should be filled with correct values. This would reduce the # of classes, and add functionality to the package. An example to explain what said above: current month: october 2003 starting day: monday Since 2003-10-01 is a wednesday, there are two empty days at the start of the month. They should be replaced by the last two days of september, with an "empty=true" flag. =[code snip]======================= $month = new Calendar_Month_Weekdays(2003, 10); $month->build(); while ($day = &$month->fetch()) { print_r($day); echo '<hr />'; } =[/code snip]======================= =[output]======================= calendar_day Object ( [cE] => calendar_engine_unixts Object( ) [validator] => [year] => 2003 [month] => 9 [day] => 29 [hour] => 0 [minute] => 0 [second] => 0 [selected] => [children] => Array( ) [first] => [last] => [empty] => true ) ----------------------------------- calendar_day Object ( [cE] => calendar_engine_unixts Object( ) [validator] => [year] => 2003 [month] => 9 [day] => 30 [hour] => 0 [minute] => 0 [second] => 0 [selected] => [children] => Array( ) [first] => [last] => [empty] => true ) calendar_day Object ( [cE] => calendar_engine_unixts Object ( ) [validator] => [year] => 2003 [month] => 10 [day] => 1 [hour] => 0 [minute] => 0 [second] => 0 [selected] => [children] => Array ( ) [first] => [last] => [empty] => false ) calendar_day Object ( [cE] => calendar_engine_unixts Object ( ) [validator] => [year] => 2003 [month] => 10 [day] => 2 [hour] => 0 [minute] => 0 [second] => 0 [selected] => [children] => Array ( ) [first] => [last] => [empty] => false ) and so on... =[/output]======================= Just my 0.02$ Best regards, Lorenzo

« previous php.pear.dev (#22984) next »