Hi Everyone, Very new to this list, first post in fact. Can anyone help me with the fmt atribute of DTML, or at least point me to some examples ... Consider the following: I need to format 2001-12-31 00:00:00.00 as 31-12-2001 I need to format 0.00 as nothing (leave blank) I need to format -2,782.50 as 2,782.50 (absolute) Can anyone help? Thanks in advance Best Regards, Sandy Donaldson +------------------------------------------------------------+ | TaskForce Systems Ltd, Jersey +44 1534 632 100 | | TaskForce Research Limited, Cardiff, UK +44 2920 504 090 | | http://www.taskforce.co.uk | | eMail : support@taskforce.co.uk (For support issues) | | : research@taskforce.co.uk (For R&D issues) | +------------------------------------------------------------+
Hi, Check out http://www.zopelabs.com/cookbook/990690237 That should get you going. Best Regards, Machiel van der Wal Piranha IT Jan Ligthartstraat 1 1817 MR Alkmaar Tel: +31 (0)72 512 14 92 Fax: +31 (0)72 512 67 29 http://www.piranha-it.nl -----Oorspronkelijk bericht----- Van: zope-admin@zope.org [mailto:zope-admin@zope.org] Namens Sandy Donaldson Verzonden: Wednesday, October 30, 2002 10:43 AM Aan: Zope List Onderwerp: [Zope] Examples of using the fmt attribute Hi Everyone, Very new to this list, first post in fact. Can anyone help me with the fmt atribute of DTML, or at least point me to some examples ... Consider the following: I need to format 2001-12-31 00:00:00.00 as 31-12-2001 I need to format 0.00 as nothing (leave blank) I need to format -2,782.50 as 2,782.50 (absolute) Can anyone help? Thanks in advance Best Regards, Sandy Donaldson +------------------------------------------------------------+ | TaskForce Systems Ltd, Jersey +44 1534 632 100 | | TaskForce Research Limited, Cardiff, UK +44 2920 504 090 | | http://www.taskforce.co.uk | | eMail : support@taskforce.co.uk (For support issues) | | : research@taskforce.co.uk (For R&D issues) | +------------------------------------------------------------+ _______________________________________________ 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 )
Sandy Donaldson wrote:
Can anyone help me with the fmt atribute of DTML, or at least point me to some examples ...
ironicly, none of these are best solved with fmt ;-)
I need to format 2001-12-31 00:00:00.00 as 31-12-2001
<dtml-var "x.strftime('%d-%m-%Y')">
I need to format 0.00 as nothing (leave blank)
<dtml-var x null=""> (maybe) <dtml-if x><dtml-var x></dtml-if> (definitely)
I need to format -2,782.50 as 2,782.50 (absolute)
<dtml-if "x>0"><dtml-var x><dtml-else><dtml-var "-x"></dtml-if> Personally, I'd recommend you get the online Zope book and learn ZPT instead. The above examples become:
I need to format 2001-12-31 00:00:00.00 as 31-12-2001
<tal:x content="python:x.strftime('%d-%m-%Y')">31-12-2001</tal:x>
I need to format 0.00 as nothing (leave blank)
<tal:x content="x" condition="x">0.00</tal:x>
I need to format -2,782.50 as 2,782.50 (absolute)
<tal:x content="python:abs(x)">2,782.50</tal:x> cheers, Chris
participants (3)
-
Chris Withers -
Machiel van der Wal -
Sandy Donaldson