You can use my $DateXpander
identifier if you want. It correctly calculates months and years (even with leap years) and works basically like $duration.
It works by counting backwards in the most basic syntax. So if you give it 33457767 seconds as the time difference, it will calculate from the current time/date backwards that many seconds and tell you that the duration is 1 year, 3 weeks, 1 day, 5 hours, 49 minutes, and 27 seconds
. Of course, you can limit the items that show up if you don't want to see the seconds or minutes or whatever. If you were to make it not show years, then it would give you 12 months instead as the beginning of the output rather than just dropping the year part.
You can see the examples on the posts on the link above for different ways you can use it.
Note also that you *can* go into the future by including a start date (you're still counting backwards, so you'd calculate it from that future start date). This is a little more complicated, but it's useful for counting down until a specific date (Christmas, birthday, etc).
This will show the time until Christmas.
//echo -a $DateXpander($calc($ctime(Dec 25 2007 00:00:00) - $ctime),12/25/2007)
Note that the calculation is giving the duration in seconds between today's date and the future date (just like if you gave any other number of seconds to calculate a $duration). The start date is after the comma.