[pmwiki-users] How to: calculate how many days left

Peter & Melodye Bowers pbowers at pobox.com
Tue Feb 26 01:19:37 CST 2008

> Date: 2008-03-05
> Apptmt: Lunch with Sam
> {(set -q xnow = (ftime fmt="%Y") * 365)}
> {(set -q xthen = (ftime fmt="%Y" when={$:Date}) * 365)}
> {(set -q ynow = (ftime fmt="%j"))}
> {(set -q ythen = (ftime fmt="%j" when={$:Date}))}
> {(set -q diff = $xthen + $ythen - $xnow - $ynow)}
> {(echo "Don't forget your appointment ({$:Apptmt}) in $diff days")}

Obviously this doesn't take into account leap year.  Various conditionals
are possible, but I'm guessing not worth the effort...

BTW the problem with doing it all in one line is that (ftime "fmt="%j")
results in something like 057.  Because of the leading 0 it gets interpreted
as an octal.  By the time that problem is solved the multi-line set is
probably easier...


More information about the pmwiki-users mailing list