[Zope] Subtracting DateTimes?????

Curtis Maloney curtis@cardgate.net
Fri, 6 Oct 2000 10:01:58 +1100


On Fri, 06 Oct 2000, Daniel Rusch wrote:
> We backup our database every night at 3:00 AM CT. 15 minutes prior to
> this (i.e. 2:45 AM) I would like to display a warning.
> How do I compare the current time <dtml-var
> "(ZopeTime()).toZone('US/Central')"> to 3:00 AM Central Time ?????
>
> <dtml-if "(ZopeTime()).toZone('US/Central') - 0.3"> doesn't work.
>
> Any thoughts???
>

Either convert to Unix time (seconds since the epoch) by coercing the date to 
an integer, or try something like:

<dtml-if "_.DateTime('%s 3:00 US/Central' % 
(_.DateTime().toZone('US/Central'))) == _.DateTime()">

_.DateTime('%s 3:00 US/Central' % (_.DateTime().toZone('US/Central'))) works 
for me to create '3am today' US/Central time...

>
> Dan
>

Curtis