Dave Cross wrote:
ecocode wrote:
Hi,
I'd like to insert a calculated date in a template .
I tried this :
[% USE date %]
[% calc = date.calc ; monday = calc.Today_and_Now ; monday =
Add_Delta_Days(monday,7) %]
[% monday.join('/') %]
But it does not work. I think it is due to the format of monday which I
think should be 3 vars...
Any idea cos I'm blocking on this :-/
Well, you're right that you need to get the three individual parts of
monday to pass into Add_Delta_Days. But you also need to call
Add_Delta_Days as a method on the calc object. This seems to work:
[% USE date %]
[% calc = date.calc ; monday = calc.Today_and_Now ; monday =
calc.Add_Delta_Days(monday.0,monday.1,monday.2,7) %]
[% monday.join('/') %]
But as Bruce points out, you'd be much better off using the DateTime
module - and there's a Template::Plugin::DateTime.
This is what should work:
[% USE date = DateTime(today = 1);
date.add(days => 7);
date.dmy('/') %]
But it looks like that "date.add" produces some output. So I had to use
this instead:
[% USE date = DateTime(today = 1);
date = date.add(days => 7);
date.dmy('/') %]
Dave...
--
Site: http://dave.org.uk/
Blog: http://blog.dave.org.uk/
Code: http://dave.org.uk/code/
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates