Hi all, I have some problems with DateTime in Zope. I generally want dates in the form 'YYYY-MM-DD'. But I can't figure out an easy way to get this with DateTime objects. There is a ISO method that produces both date and time: 'YYYY-MM-DD HH:MM:SS'. But nothing to get only the date. Perhaps one could wish for some addtions to the DateTime class. Some possibilities are, in order of preference: 1. Configurable default data format. 2. An ISODate method. 3. strftime method that uses localtime and not gmtime. Any other suggestions how to do this? -- Lennart Staflin <lennarts@infotek.no> /*/ STEP Infotek AS, http://www.infotek.no/ Gjerdrums vei 12, N-0486 Oslo, Norway
I have some problems with DateTime in Zope. I generally want dates in the form 'YYYY-MM-DD'. But I can't figure out an easy way to get this with DateTime objects. There is a ISO method that produces both date and time: 'YYYY-MM-DD HH:MM:SS'. But nothing to get only the date.
Perhaps one could wish for some addtions to the DateTime class. Some possibilities are, in order of preference:
1. Configurable default data format. 2. An ISODate method. 3. strftime method that uses localtime and not gmtime.
<dtml-call "REQUEST.set('a',_.DateTime())"> <dtml-call "REQUEST.set('your_date','%s-%s-%s' %(a.year(),a.mm(),a.dd()))"> <dtml-var your_date> Is already tested. PM
I have some problems with DateTime in Zope. I generally want dates in the form 'YYYY-MM-DD'. But I can't figure out an easy way to get this with DateTime objects. There is a ISO method that produces both date and time: 'YYYY-MM-DD HH:MM:SS'. But nothing to get only the date.
Perhaps one could wish for some addtions to the DateTime class. Some possibilities are, in order of preference:
1. Configurable default data format. 2. An ISODate method. 3. strftime method that uses localtime and not gmtime.
Try this: YYYY-MM-DD HH:MM:SS <dtml-var "_.DateTime(thistime).ISO()"> YYYY-MM-DD <dtml-var "_.DateTime(thistime).ISO()[:10]"> Also take a look at the lib/python/DateTime/DateTime.py for the other methods available. I guess here we find what the meaning of "the source is the documentation". Oh well it gets one more into the guts of it all - that can't be all bad. --Hope this helps. -- ------------------------------- tonyr@ep.newtimes.com Director of Web Technology New Times, Inc. -------------------------------
i do this (a little clumsily) via <dtml-var t1 fmt="year">-<dtml-var t1 fmt="mm">-<dtml-var t1 fmt="dd"> provided t1 is a date var. (this is from the very useful zope quick ref., http://www.zope.org/Members/ZQR) hth peter. On 12 Apr 2000, Lennart Staflin wrote: :Hi all, : :I have some problems with DateTime in Zope. I generally want dates in :the form 'YYYY-MM-DD'. But I can't figure out an easy way to get this :with DateTime objects. There is a ISO method that produces both date :and time: 'YYYY-MM-DD HH:MM:SS'. But nothing to get only the date. : :Perhaps one could wish for some addtions to the DateTime class. Some :possibilities are, in order of preference: : :1. Configurable default data format. :2. An ISODate method. :3. strftime method that uses localtime and not gmtime. : :Any other suggestions how to do this? : : -- _________________________________________________ peter sabaini, mailto: sabaini@niil.at -------------------------------------------------
participants (4)
-
Lennart Staflin -
Marcel Preda -
Peter Sabaini -
Tony Rossignol