> -----Original Message-----
> From: Andrew Ballard [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 04, 2008 8:32 AM
> To: Angelo Zanetti
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Last working day of a month
> Importance: Low
> 
> On Thu, Dec 4, 2008 at 9:03 AM, Angelo Zanetti <[EMAIL PROTECTED]>
> wrote:
> > Hi all,
> >
> > I am busy trying to figure out how to get the last working day in a
> month.
> >
> > I was wondering if there was a script already written, but this is
> what I
> > imagine should work:
> >
> > Get the current day and see if it's the last day of the month. If its
> true
> > check if it's a Saturday or Sunday if it's either of those 2 days
> then
> > return false else return true?
> >
> > I also need to take public holidays into account. What would be the
> best
> > solution for that? Store the public holidays in a table and check if
> the
> > current day isn't a public holiday?
> >
> 
> If your application is already using a database, I would use a date
> table rather than a holiday table. You can add columns to indicate
> whether each date is a workday, weekday, weekend, holiday, or any
> other date category/group that you need to track.

That seems like a waste of space and database calls to me. (Yes, I know space 
is cheap... but it should at least be thought about briefly. Using that space 
costs cycles, etc.) Since the exceptions to his rule are so few in comparison 
to the days that follow, I think documenting the exceptions and assuming it's a 
workday if it's not an exception makes more sense (IMHO).

I'd probably store all holidays in a table and assume that Saturdays/Sundays 
are not workdays unless they have a corresponding entry in the same table that 
holds the holidays. Call the table "exceptions." The exception to a workday is 
a holiday. The exception to a weekend is a workday. :)

HTH,


// Todd

Reply via email to