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

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 :)

  • Comment on Re^2: Calculating next business day (weekends/holidays taken into account)

Replies are listed 'Best First'.
Re^3: Calculating next business day (weekends/holidays taken into account)
by afoken (Chancellor) on Jun 24, 2009 at 21:51 UTC

    Obligatory link: Yes, even you can use CPAN

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: Calculating next business day (weekends/holidays taken into account)
by Herkum (Parson) on Jun 24, 2009 at 21:16 UTC

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

      nope..

      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 { } ? :)

        The old way you had to do it was Time::Local (which you are using) and localtime. Convert back and forth between date representations and epoch time.

        Create a constant that contains the value of a days worth of seconds (60 * 60 * 24). When you need to increment a day get the epoch and add a days worth of seconds, then convert that back to your date. Once you have that date, check if that new date is a business day or not. I would use noon as your HH:MM:SS when you convert from date to epoch.

        This is a lot more work and you have to deal with localtime's 0 and 1 based ranges. Break everything down to small manageable subs. One for date to epoch and the other way.

        grep
        One dead unjugged rabbit fish later...