[Zope] formatting date values.

Rob Page rob.page@digicool.com
Sat, 24 Jul 1999 19:55:56 -0400


> I've been wondering how one can format with the var tag a 
> date value as
> DD.MM.YYYY or DD/MM/YYYY?

Enclosed is snippet of UNSUPPORTED, NOT-IN-CVS, CAVEAT EMPTOR, YMMV code
that you might be able to put in DateTime.py

_Possibly_ with Jim's blessing and a little documentation tweak these
_might_ get into CVS...

[Did I hedge enough?]

    # New formats

    def aDotIntlDate(self):
        """Return a string representing the object\'s value
           in the format: 21.03.1999"""
        return '%.2d.%.2d.%.4d' % (
               self._day, self._month, self._year)

    def aSlashIntlDate(self):
        """Return a string representing the object\'s value
           in the format: 21/03/1999"""
        return '%.2d/%.2d/%.4d' % (
               self._day, self._month, self._year)

you would then use something like:

<!--#var bobobase_modification_time fmt=aDotIntlDate-->
or
<!--#var bobobase_modification_time fmt=aSlashIntlDate-->

To answer a related question, we are considering mechanisms by which the
process for adding new:

o  time expressions
o  timezones
o  currency expressions

etc., is much less dependent on the current patch-the-code mechanism and
would thereby let people _easily_ define their own date and currency
formats without having to repatch their software every time a release is
made.  Of course, the Z2 alpha and beta process has taken some attention
away from this.  I would encourage you to join the Zope
Internationalization Project (ZIP).

--Rob