[Zope] ZopeTime().Date() confusion

Larry Albert lda@rice.edu
Mon, 02 Oct 2000 00:38:25 -0500


This is driving me batty.

I am trying to do something very simple. I want a method to perform an
update no more than once a day. I know there are other approaches to this
issue -- such as using bobobase_modification_time, not to mention Xron --
but I would like to use a date property for reasons I won't go into here.

I am using Zope 2.2.1. Every time the method updates, I update the date
property called last_updated with this: 

<dtml-call "manage_changeProperties(last_updated=ZopeTime().Date())">

This gives me a date that appears to be accurate, such as 2000/10/01. Then,
every time the page gets called, I want to check to see if it is time to
call the method, so I use:

<dtml-if expr="last_updated.isCurrentDay()">
	don't update method
<dtml-else>
   update method
   store new last_updated
</dtml-if>

This worked fine until, at the appointed hour, last_updated began to sense
that even though it appeared to be "2000/10/01" (and even when I typed it
in that way by hand), the time in Greenwich was actually more important to
its sense of identity than was its appearance to me. So even when
ZopeTime().Date() gave me 2000/10/01, 

last_updated.isCurrentDay() 

would evaluate to false(!). So the method would update every time the page
was called. As a kluge, I changed my update command to 

<dtml-call
"manage_changeProperties(last_updated=ZopeTime().toZone('GMT').Date())">

, which works, but causes the update to occur, I presume, at midnight GMT,
rather than midnight here, which would be nicer (actually, I'd love to be
able to control the precise hour updates should occur, but I can't figure
out how to do that). This is also complicated -- but not relevantly, I
hope? -- by the fact that the Zope installation seems to think the time
zone is GMT+2 rather than GMT-5 (I'm in Texas).

I understand that the previously counterintuitive use of strftime was
changed for 2.2.1 -- but I am not using strftime, I am using Date() and
isCurrentDay(). I've tried all sorts of combinations of switching time
zones but succeeded only in confusing myself.

So three questions:

1. Is there a better way to do this (still using a property called
last_updated)?

2. Does the use of Date() and isCurrentDay(), etc. still switch everything
to GMT, even though strftime was changed? If so, what is the list of
methods that compare GMT, and which that compare the local installation time?

3. This appears to be a perfect example of something that should be very
simple becoming needlessly complicated. Couldn't some more user-friendly
("beginner") time or date objects be implemented in DTML?

Thanks for any help!

Larry Albert
lda@rice.edu