- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Is this a leap year?
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 02:15 PM
02-28-2003 02:15 PM
My boss just asked me late on a Friday afternoon if I could come up with an easy way to know if tomorrow will be Feb. 29 or March 1. I plan to run a cron script on 02 28 at 8PM each year.
Any quick ideas so that I can leave?
Please help, Bob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 02:19 PM
02-28-2003 02:19 PM
SolutionWell, we could go through the year % 4, not century year unless divisdible by 400 but why bother?
if [[ $(caljd.sh -n 1 -M) != $(caljd.sh -M) ]]
then
echo "This is a leap year"
else
echo "This ain't no leap year"
fi
This does assume that you run it only on 02/28.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 02:19 PM
02-28-2003 02:19 PM
Re: Is this a leap year?
Search the forum for caljd.sh or caljd.pl
These are Clay's date hammers & they will do anything with dates that you could ever desire.
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 02:20 PM
02-28-2003 02:20 PM
Re: Is this a leap year?
The rule of thumb has always been if the year is divisible by 4 then it is a leap year.
Unless it is divisible by 100, then it is not.
Unless it is divisible by 400, then it is.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 02:24 PM
02-28-2003 02:24 PM
Re: Is this a leap year?
Clay, the -M tells the "date hammer" to output the month. Is this correct? All you are doing is seeing if tomorrow is a different month? Now why couldn't I figure that out?
Thanks and it looks like I will be outa here soon!!!
This place rocks.
Thanks again,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 02:27 PM
02-28-2003 02:27 PM
Re: Is this a leap year?
Yes, that's all that I'm doing. Now as to why you couldn't figure that out - well, I could come up with a few possible answers but you probably wouldn't like them.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 04:18 PM
02-28-2003 04:18 PM
Re: Is this a leap year?
THEN
ELSE
END
8^) --bmr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2003 04:22 PM
02-28-2003 04:22 PM
Re: Is this a leap year?
p=$(cal 2 2003 | tail -2)
set -u $p
eval j=\$$#
if [ $j == "28]; then
echo 2003 is not leap
else
echo leap year
fi