1752795 Members
6456 Online
108789 Solutions
New Discussion юеВ

caljd.sh

 
SOLVED
Go to solution
Charles McCary
Valued Contributor

caljd.sh

Mr. Stephenson,

Just downloaded your script and it's great. One question for you though regarding this usage:

cal.sh -Y -s $(cal.sh -p 1)

This produces yesterday's date in the following format:

20020507

Does this work across years, so that when I run this script on 20030101, it will still output 20021231?

Does this have any problems with leap years?

Are there any downfalls with using this when I always want to produce only yesterday's date?

I'm sure I'm just being paranoid (what sysadmin isn't a little paranoid) but I'll sleep better hearing it from the Author's fingertips.

tx,
c
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: caljd.sh

Hi Charles:

Does a hog like slop? Julian days count sequentially from 4713BCE to far into the future. They are used by astronomers to simplify orbital calculations. It knows all about leap years, about century years not being leap years (unless divisble by 400) and it knows all this without a single if statement. It also does "30 Days hath September ..." without an if statement. By the way, there is a newer Perl based version 'caljd.pl' with exactly the same arguments/options as caljd.sh.

I suggest that you download caljd.pl and try it as well; it executes quite a bit faster than the Shall/awk based 'caljd.sh'.

Version 2.05 is the latest version of both.




Regards, Clay
If it ain't broke, I can fix that.
Charles McCary
Valued Contributor

Re: caljd.sh

Thanks - that's what I needed.