RE: ZopeTime questions (continued)
I wrote:
5) If I want to make a simple time comparison between release date property of an object and current time, how do I do it (e.g. if I only want to compare, say that the dates are same - not caring about years, months or hours and seconds). If my current object has a property release which has been set to ZopeTime at the time of creation:
Actually I found out that isCurrentDay() does what I want. If I want to check whether object X with a timestamp property "release" has a value that matches today (the date, the month, the year, not hours nor minutes), then I can do: <dtml-if "release.isCurrentDay()"> do my thing... </dtml-if> and it works. Thanks for the help to Martijn and others. Now if I could only do the following (here in dtml-pseudo code)... <dtml-with #current_year_taken_from_ZopeTime#> <dtml-with #current_month_taken_from_ZopeTime#> #do my thing# </dtml-with> </dtml-with> #current_year_taken_from_ZopeTime# needs to be a number/string, e.g. 1999 #current_month_taken_from_ZopeTime# needs to be a number/string, e.g. 10 i.e. I don't want the whole timestamp ZopeTime gives, just year or month ...then I'd be a happy camper :) The following do not work: <dtml-with ZopeTime fmt=year> (fmt is not attribute for with?) <dtml-with <dtml-var ZopeTime fmt=year> > (I didn't think so :) <dtml-call "REQUEST.set('release', ZopeTime fmt=day)> (invalid syntax) I'm starting to figure i need to resort to the DateTime()-method instead of calling the ZopeTime object, but I'm not sure how... Best regards, Samu Mielonen PS I found out an earlier post by Michel Peltier that almost does what I want (it uses the Catalog to do a search). This list is great for begginers like me. Thanks again to everyone.
At 14:53 15/10/99 , Samu Mielonen wrote:
Now if I could only do the following (here in dtml-pseudo code)...
<dtml-with #current_year_taken_from_ZopeTime#> <dtml-with #current_month_taken_from_ZopeTime#> #do my thing# </dtml-with> </dtml-with>
#current_year_taken_from_ZopeTime# needs to be a number/string, e.g. 1999 #current_month_taken_from_ZopeTime# needs to be a number/string, e.g. 10 i.e. I don't want the whole timestamp ZopeTime gives, just year or month
...then I'd be a happy camper :)
The following do not work:
<dtml-with ZopeTime fmt=year> (fmt is not attribute for with?)
<dtml-with <dtml-var ZopeTime fmt=year> > (I didn't think so :)
<dtml-call "REQUEST.set('release', ZopeTime fmt=day)> (invalid syntax)
<dtml-let month="ZopeTime().month()" year="ZopeTime.year()"> .. here you can use month and year in your code .. </dtml-let> or <dtml-call "REQUEST.set('month', ZopeTime().month())"> <dtml-call "REQUEST.set('year', ZopeTime().year())"> to place them in the REQUEST object. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
From: Martijn Pieters [mailto:mj@antraciet.nl]
<dtml-let month="ZopeTime().month()" year="ZopeTime().year()"> .. here you can use month and year in your code .. </dtml-let>
Yup. After that code: <dtml-var year> is 1999 and <dml-var month> is 10 but <dtml-with "_[year]"> inside the above <dtml-let> statement gives me: Error Type: SystemError Error Value: bad argument to internal function while: <dtml-with 1999> works ok (i.e. goes inside folder with id 1999 and iterates through it) I've also tried replacing the above let-statement with: <dtml-call "REQUEST.set('month', ZopeTime().month())"> <dtml-call "REQUEST.set('year', ZopeTime().year())"> after which: <dtml-var year> is 1999 and <dml-var month> is 10 but again after the above: <dtml-with "_[year]"> gives me: Error Type: SystemError Error Value: bad argument to internal function So, apparently I do not know how to reference inside folder X (with dtml-with) where X is the name of the folder taken from property "year". I am somehow not able to pass the contents of property "year" to the <dtml-with> tag as an argument. How do I accomplish this? Again, thanks for the input so far - it's been very helpful. Best regards, Samu Mielonen
On Fri, 15 Oct 1999, Samu Mielonen wrote:
<dtml-with "_[year]">
Try <dtml-with "_['year']"> Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN.
At 17:32 15/10/99 , Samu Mielonen wrote:
From: Martijn Pieters [mailto:mj@antraciet.nl]
<dtml-let month="ZopeTime().month()" year="ZopeTime().year()"> .. here you can use month and year in your code .. </dtml-let>
Yup. After that code:
<dtml-var year> is 1999 and <dml-var month> is 10
but
<dtml-with "_[year]">
inside the above <dtml-let> statement gives me:
Error Type: SystemError Error Value: bad argument to internal function
Hmm.. look into the source of the errorpage for a traceback, we might need it. In the meantime, try this: <dtml-with "_[_.str(year)]"> But that is just a guess. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (3)
-
Martijn Pieters -
Oleg Broytmann -
Samu Mielonen