Hi I am having trouble performing date calculations in Zope. I have a variable called dob which returns a date of birth from MySQL Ie. Date of Birth=<dtml-var dob> works fine I would like to be able to list the current age in years and months I can get a years calculation with the following line Age in years = <dtml-var expr="ZopeTime().year()-dob.year()"> A similar line works using months Months = <dtml-var expr="ZopeTime().month()-dob.month()"> I don't know how to do the month above when say you are in month 1 and you subtract month 12 Also, how can the results be placed in a form. Eg <INPUT TYPE="TEXT" NAME="AgeYears" value="0"> <INPUT TYPE="TEXT" NAME="AgeMonths" value="0"> I tried putting the above dtml-var code in the value attributes without success. Thanks Greg
On Sun, 15 Dec 2002, Greg McCall wrote:
Hi I am having trouble performing date calculations in Zope. I have a variable called dob which returns a date of birth from MySQL Ie. Date of Birth=<dtml-var dob> works fine I would like to be able to list the current age in years and months
Read the DateTime() API carefully and use it.
Thanks but like the API reference, which I did check, and your information gives little help in how to solve the problem. The reference doc is far too cryptic. It should show examples which can be directly tried in Zope. A quick check of the web version of the book (something I would not normally use) I find the following note added: (and it seems its author is also not impressed with the doc) <dtml-var expr="_.DateTime()"> The comments also supply the following URL http://www.zopelabs.com/cookbook/990690237 And this seems like an important example of how to display time stuff (no calculations though) using DateTime() Another date example using ZopeTime() is at http://www.zope.org/Members/jooi/HowToDateCalculation I don't know why ZopeTime() exists as well as DateTime() or which routine is best. I do know Zope is often does things in obscure ways with little help and that comments like yours suggest the doc is fine and it must just be the user who will not read the info (all of it and keep all the bits in your head just to do a few simple jobs) -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org] On Behalf Of Dennis Allison Sent: Sunday, December 15, 2002 10:24 AM To: Greg McCall Cc: zope@zope.org Subject: Re: [Zope] Date calculations in Zope On Sun, 15 Dec 2002, Greg McCall wrote:
Hi I am having trouble performing date calculations in Zope. I have a variable called dob which returns a date of birth from MySQL Ie. Date of Birth=<dtml-var dob> works fine I would like to be able to list the current age in years and months
Read the DateTime() API carefully and use it. _______________________________________________ Zope maillist - Zope@zope.org 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 )
participants (2)
-
Dennis Allison -
Greg McCall