Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: Calculating next business day (weekends/holidays taken into account)

by grep (Monsignor)
on Jun 25, 2009 at 02:46 UTC ( #774574=note: print w/ replies, xml ) Need Help??


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

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...


Comment on Re^5: Calculating next business day (weekends/holidays taken into account)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://774574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (18)
As of 2015-07-30 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls