Re: [Zope] ZopeTime().Date() confusion

2000-10-02 Thread Dieter Maurer

Larry Albert writes:
  
  I am using Zope 2.2.1. Every time the method updates, I update the date
  property called last_updated 
 
  checking last update at least 1 day ago 

"ZopeTime()" returns a "DateTime.DateTime" object.
Such objects can be substracted giving the difference
in days.

This means, you can use:

dtml-call "manage_changeProperties(last_updated=ZopeTime()"

to set "last_updated" and

dtml-if "ZopeTime() - last_updated = 1"

to check that the last update is at least 1 day ago.


Dieter



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] ZopeTime().Date() confusion

2000-10-01 Thread Larry Albert

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
[EMAIL PROTECTED]



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )