in reply to Calculating next business day (weekends/holidays taken into account)

You need to increment the day by one and check if it's not a holiday/weekend day. But incrementing days gets hairy, so use one of the great date modules from cpan to do it. I use Date::Calc or for an OO module DateTime.

In fact converting you entire script to use DateTime for dates would be a good thing. It'll end up being far more maintainable in the long run, and looking at what you have so far not to much of a change.

One dead unjugged rabbit fish later...
  • Comment on Re: Calculating next business day (weekends/holidays taken into account)

Replies are listed 'Best First'.
Re^2: Calculating next business day (weekends/holidays taken into account)
by vxp (Pilgrim) on Jun 24, 2009 at 20:25 UTC

    Unfortunately, I am not allowed to install anything on the box the script will be running from. That includes CPAN modules :/

    This is why I'm jumping through hoops there, with my get_day() sub :)

      Obligatory link: Yes, even you can use CPAN


      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Can you install it for your user account that will run the script? Then you can alter the 'lib' search path.


        after some discussion in the chatterbox it was determined that the only way to use modules (and still comply with the security policies on that box) is to just copy/paste them into my script. it sucks, but its the only way. :/

        so, keeping that in mind - any ideas for my sub get_next_business_day { } ? :)