Re: [PEPr] Comment on Date and Time::Date_Holidays
| From: | Sergio Carvalho | Date: | Mon, 21 Jun 2004 13:31:58 +0000 |
| Subject: | Re: [PEPr] Comment on Date and Time::Date_Holidays | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-31026@lists.php.net to get a copy of this message | ||
Pepr wrote:
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Antônio Carlos Venâncio Júnior (http://pear.php.net/user/antonio) has commented on the proposal for Date and Time::Date_Holidays. Comment: Are you planning to add support to differentiate national/state/city holidays? Proposal information: http://pear.php.net/pepr/pepr-proposal-show.php?id=85From the comments above, including the response to my own comment, I think the author plans on following a Driver-only approach, with Driver combination and holiday filtering to allow for city/state holidays. Although the driver approach seems really sane, because some holidays have really exquisite calculation rules, I want to reiterate that following a Driver route for city holidays is explosive in class count. Portugal is a small country (10 million people), and here alone there are hundreds of different cities, with city-holidays. Having one driver per city isn't ok, and having a couple of lines of code per city isn't much better either. There will be serious issues with maintainability. Holidays probably follow the 80-20 rule: 80% of holidays can be described using simple dates or relative dates with simple anchors. Perhaps these can be described in data files, and the 20% complicated holidays be left in specific drivers. Even these drivers can delegate most holidays to a data file, and get cleaner code. Using this approach, I could produce a holiday calendar for my home city like this:
$porto = &Date_Holidays::factory('DataFile', 'Porto_PT');
$portugal = &Date_Holidays::factory('Portugal');
$porto_Portugal = &Date_Holidays::factory('Composite');
$porto_Portugal->addDriver($porto);
$porto_Portugal->addDriver($portugal);
And since we're hosting the Euro 2004 and winning games, nobody is working the day after a national team match, so I can quickly wip up a transient holiday data file ;-)
$euro = &Date_Holidays::factory('DataFile', 'Euro2004');
$porto_Portugal->addDriver($euro);
Cheers,
Sérgio Carvalho
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc