[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Using Zope Page Templates

webmaster@zope.org webmaster@zope.org
Thu, 07 Nov 2002 06:23:59 -0500


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx#2-73

---------------

    You can also fix the date formatting problems with a little
    Python. Create a script named 'file_date' in your 'FileLib'
    folder::

      ## Script (Python) "file_date"
      ##
      """
      Return modification date as string YYYY/MM/DD
      """
      date=context.bobobase_modification_time()
      return "%s/%s/%s" % (date.year(), date.mm(), date.day())

      % Anonymous User - May 23, 2002 3:11 pm:
       Should that be date.month() instead of date.mm()?

      % Anonymous User - May 23, 2002 3:25 pm:
       Well, mm() returns a zero-padded string while month() returns an integer. 

       >>> app.ZopeTime().mm()
       '05'
       >>> app.ZopeTime().month()
       5

       It could go either way.

      % Anonymous User - June 4, 2002 9:09 am:
       OK, but the month is now zero padded but the day isn't. Looks kinda funny, I.E 2002/06/5 Either use month or
       use the zero padded day too for consistancy. I'm not a Python'er so I don't have any idea how to get a zero
       padded day.

      % Anonymous User - June 11, 2002 6:06 pm:
       throretically:
       (date.year(), date.mm(), date.dd())

       however it's now the 11th and I'll have to wait until next month to find out for sure...  ;)

       "another newbie"

      % Anonymous User - Aug. 5, 2002 11:08 pm:
       In the book, I find that there are few named objects which mysteriously appear without explanation. In this
       case the "context" object in the script is what is mysterious.
       I understand that it is the readers responsibility to figure out what this is, but by going the traditional
       route of looking it up in the online documentation, I cannot find information about this "context" object.

      % Anonymous User - Nov. 7, 2002 6:23 am:
       how about time? how do you display it?