[ZPT] Equivalent for <dtml-var dateobj fmt=ISO>?
Casey Duncan
casey@zope.com
Tue, 13 Aug 2002 12:12:18 -0400
DateTime objects have a strftime method useful for formatting. For exampl=
e:
<span tal:replace=3D"python:here.ZopeTime().strftime('%m/%d/%Y')" />
Inserts: 03/13/2002
If you use the same date format in lots of places, I would suggest creati=
ng a=20
python script called something like "fmtDate" with a single parameter "da=
te"=20
that does the formatting (so you can change it everywhere from one place)=
:
return date.strftime('whatever fmt')
Then you can do:
<span tal:replace=3D"python:here.fmtDate(here.aDate)" />
hth,
Casey
P.S. This would be another example of where Shane's piping idea might hel=
p,=20
but that's another story.
On Tuesday 13 August 2002 11:22 am, Jean Jordaan wrote:
> Hi all
>=20
> Bit of a newbie question I guess:
> what's the ZPT equivalent for <dtml-var dateobj fmt=3DISO>?
>=20
> The best lead I've found so far, was:
> http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/AdvZPT.stx#=
4-102
> which says:
>=20
> the "standard" module in this package provides a number of useful
> formatting functions that are standard in the DTML "var" tag.
>=20
> to be got at like so:
>=20
> tal:define=3D"global pps modules/Products/PythonScripts/standard"
>=20
> The fmt functionality is in DT_Var.py, which I'd guess is accessible
> as:
>=20
> tal:define=3D"global dtvar modules/DocumentTemplate/DT_Var"
>=20
> But what would I do with 'dtvar'?
>=20
> --=20
> Jean Jordaan
> Upfront Systems http://www.upfrontsystems.co.za
>=20
>=20
>=20
> _______________________________________________
> ZPT mailing list
> ZPT@zope.org
> http://lists.zope.org/mailman/listinfo/zpt
>=20