1825775 Members
2305 Online
109687 Solutions
New Discussion

Next workday

 
SOLVED
Go to solution
John Wolfe_1
Advisor

Next workday

Hi experts:

Does anyone have a way to get the next workday? If it's Monday through Thursday, I need the next day but if it's Friday, I need the next Monday?
Is there an easy solution?

Thanks,
John
At least I have a job.
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Next workday

Does a hog like slop?

NW_DAY=$(caljd.sh -S "/" $(caljd.sh -n 1 -x 6 -x 0))
echo "Next workday = ${NW_DAY}"

Invoke as caljd.sh -u for full usage.

If it ain't broke, I can fix that.
Pete Randall
Outstanding Contributor

Re: Next workday

Go to Merijn's page ( http://mirrors.develooper.com/hpux/ ), scan down until you find Clay's caljd.sh script. Download and install it and review the usage notes.


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: Next workday

I should also add that you can skip holidays defined in the /etc/acct/holidays file by adding the "-h" flag.

NW_DAY=$(caljd.sh -S "/" $(caljd.sh -n 1 -x 6 -x 0 -h))
echo "Next workday = ${NW_DAY}"

This is pretty hard to beat.
If it ain't broke, I can fix that.
RAC_1
Honored Contributor

Re: Next workday

perl -e 'print scalar localtime(time+24*60*60)'

Now you can put some if statements to get next day.

Anil
There is no substitute to HARDWORK
John Wolfe_1
Advisor

Re: Next workday

Thanks all. A. Clay's solution worked great.

Regards,
John
At least I have a job.
Hein van den Heuvel
Honored Contributor

Re: Next workday


perl -e '$days=(1,1,1,1,1,3,2)[(localtime)[6]]; print scalar localtime(time+$days*86400),"\n"'

(localtime)[6] = weekday number (0..6) for now.
(1,1,1,1,1,3,2)[x] = Use as index into array with number of days to add.
multiply those days with 24*60*60=86400 seconds in a day.
Add to current time, format and print with newline.


Hein.