[Zope] - strftime for DateTime

Jim Fulton jim@digicool.com
Thu, 07 Jan 1999 12:50:28 +0000


Simon Greenwood wrote:
> 
> In article <199901070107.UAA01736@dolphin.calendar.com>, skip@calendar.com
> () wrote:
> 
> > The appended context diff seems to do what Jim asked for.  Here's a
> > simple
> > session:
> >
> >     >>> import DateTime, time
> >     >>> dt = DateTime.DateTime(time.time())
> >     >>> dt.strftime("%Y-%m-%d")
> >     '1999-01-07'
> >     >>> getattr(dt, "%Y-%m-%d")
> >     <DateTime.DateTime.strftimeFormatter instance at 8116570>
> >     >>> getattr(dt, "%Y-%m-%d")()
> >     '1999-01-07'
> >
> > (Jim actually did all the work.  I made sure the necessary time
> > functions
> > were available at the module level and generated a context diff... :-)
> 
> I'm going to be incredibly dumb now and ask if this can now be accessed
> through DTML and how.

If you apply Skip's change to the Zope DateTime module (in the DateTime 
package), restart Zope, and can get a DateTime object (e.g. by calling ZopeTime
to get the current date and time) then you should be able to do something
like:

 <!--#var ZopeTime fmt="%Y-%m-%d"-->

Skips patch will be included in the next release.

> (Oh hi, I'm new here, Zope looks like just the thing I want but I'd
> appreciate some more obvious documentation

We're working on it. :)

> and a more transparent approach
> to object development and implementation.

I don't know what you mean by this.  What do you mean by transparent?
What sort of things would you like to be able to do?

> The problem of either publishing
> the current date

See above

> or taking a 'last updated' date from a database is just


This is:

   <!--#var bobobase_modification_time fmt="%Y-%m-%d"-->

Note however that this doesn't give the modification
time of the document, but rather the modification time 
of the folder.  This is because the current Document
objects are meant to be used as methods, not content.
A new content document object will be provided in the next
release.

These two methods illustrate the difficulty of using 
automagically generated documentation.  ZopeTime
is defined in the Application class (which heppens
not to show up in the on-line help) and is acquired
(not inherited) by most objects and, therefore, doesn't
show up in the documentation. :(  
bobobase_modification_time doesn't have the meta-data 
necessary to make the documentation machinery consider it
to be part of the API. Sigh.

> the first I've come across, although it looks like others have at the same
> time. I'm a perl/CGI veteran looking for a way not to reinvent the wheel
> for a reasonably idiot proof semi-public music/artist presentation service
> and if I get my head around it, Zope is the one. A recipe book for the
> basic functions would be a great help though,

We'd be glad to get documentation suggestions.  I know it's
had to make suggestions when you're still learning what there
is to document.  I assume that you've looked at alot of the
documentation on the Zope site.

> and I'll pitch my hand in
> for anything I can help with)

Great!

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (540) 371-6909              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.