Operating System - HP-UX
1833758 Members
2612 Online
110063 Solutions
New Discussion

How to determine if the current day is a holiday?

 
SOLVED
Go to solution
Greg White
Frequent Advisor

How to determine if the current day is a holiday?

Hello Experts,

Is there a command to tell if the current day is a holiday? I know how to tell if today is during the weekend. Is there a file that maintains this information?

Thanks,
Greg
I know how to do it in pascal.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: How to determine if the current day is a holiday?

There is a file, /etc/acct/holidays, that I bet you haven't touched in years. Bring it up to date. It's a bit tricky to parse so the easiest method would be some sort of date tool. Let's see, what might I use?

if [[ $(caljd.sh) -ne $(caljd.sh -h) ]]
then
echo "It's a holiday"
else
echo "It't ain't no holiday"
fi

Search the Forums for caljd.sh (or caljd.pl). That should fix you.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: How to determine if the current day is a holiday?

I suppose that I should add that there is also a useful tool to calculate the day offsets that are in the /etc/acct/holidays file. Let's see, what tool would that be?

To do Xmas 2004, for example:
OFFSET=$(( $(caljd.sh 12 25 2004) - $(caljd.sh 12 31 2003)) )
echo "Offset = ${OFFSET}"

This suggests a small script but I'll leave that as an exercise for you.

Invoke as caljd.sh -u and it will display full usage and examples and also mentions the holidays file. Caljd.sh actually looks for holidays_yyyy before holidays so that if New Year's Eve and New Year's Day (different years) were holidays you could skip both in the same calculation.
If it ain't broke, I can fix that.
Greg White
Frequent Advisor

Re: How to determine if the current day is a holiday?

Hi Clay,

Thanks. That worked great! I put today in the holiday file as a test and it recogized it.

When I searched for caljd.sh, I got dozens of hits.

Regards,
Greg
I know how to do it in pascal.