mmm dd Push date for current year onto stack
mmm dd yyyy Push date onto stack
n or -n Push positive/negative constant or interval onto stack
+ - * / % Add, subtract, multiply, divide, modulo
expr Push result of Perl expression onto stack
<d>uplicate Push a duplicate of the top value onto the stack
<c>lear Clear stack
<p>rint Print last value on stack
<P>rint Print all stack values
<t>oday Put today's date on the stack
e<x>change Exchange top two values of stack
<q>uit Exit the program
Note: expressions are scanned for embedded dates of the form `1991/Jan/2',
`Jan 1, 1991' or just `Jan 1'. These dates are translated to Julian
Day numbers before the expression is evaluated. Also, the tokens
`today', `tomorrow' and `yesterday' are replaced with their
respective Julian Day numbers. If the expression does something
stupid with Julian Day numbers (like add them) you get silly
results.
EOD
next;
}
else {
chop;
# replace yyyy/mmm/dd dates with Julian day number
s|(\d{1,4})\W?(\w\w\w)\W?(\d\d?)|&jday(&monthnum($2),$3,$1)|ge;
# replace mmm dd yyyy dates with Julian day number
s|(\w\w\w)[\W\s](\d\d?)[,]?[\W\s](\d{1,4})|&jday(&monthnum($1),$2,$3)|ge;
# replace mmm dd dates with Julian day number (for this year)
s|(\w\w\w)[\W\s](\d\d?)|&jday(&monthnum($1),$2)|ge;
# replace 'today' with todays jday
s|\b(today)\b|&today()|ge;
# replace 'tomorrow' with tomorrows jday
s|\b(tomorrow)\b|&tomorrow()|ge;
# replace 'yesterday' with yesterdays jday
s|\b(yesterday)\b|&yesterday()|ge;
print $_,"\n";
push(@stack,eval($_));
do print($stack[$#stack]);
next;
}
# else { warn "** invalid command - try \"help\"\n" unless ($_ eq "\n"); }
} continue {
print "> ";
$command = "";
}