datemath is a console tool that allows you to manipulate dates mathematically.
Too many times we have needed to do a bit of math on a date -- say, "today + 7 days" -- but in traditional MM/DD/YYYY format this is really tricky (especially in a shell script). A result of this need we built the datemath tool which can perform these functions from the command line or from a shell script. Examples:
$ datemath today + 5
$ datemath '12/25/2003 - today'
$ datemath today + 5 weeks
when will my machine be up for one year?
11:09am up 317 days, 15:38, 7 users, load average: 0.16, 0.04, 0.01
$ datemath today + 365 - 317
The expressions accepted by datemath are straightforward and moderately flexible. The grammer is defined to reject most things that don't make any sense (such as adding two dates together), while allowing most things that do.
· GNU flex