[Zope] How to subtract one date from another?

Steve Alexander steve@cat-box.net
Wed, 26 Apr 2000 21:45:47 +0100


Andrew Diller wrote:
> 
> Here is my contribution. I create a date attribute called targetdate that
> people modify. I want to have a simple integer on a page showing how many
> days from _now_ till that 'target date.'
> 
> Here is my snipped that works: (thanks to the previous posts)
> 
> <dtml-let now="ZopeTime()">
> <dtml-let due="targetdate">
> <b><dtml-var "_.int(_.round(due-now))"></b>
> </dtml-let></dtml-let>

One caveat here: the rounding won't be correct if you have anything to
do with daylight-savings time in your machine's timezone, or in the time
you're storing. It will most likely be an hour out.

See other posts to the list about problems with DateTime and daylight
savings.

--
Steve Alexander
Software Engineer
Cat-Box limited