(Resending from the correct address... :)
Make sure you have the latest version of Template Toolkit installed. The change to support dates with the year first was added in TT version 2.20. http://cpansearch.perl.org/src/ABW/Template-Toolkit-2.20/Changes Unfortunately, I just noticed that the version number of Template::Plugin::Date itself was not incremented with the change. Oops - my fault I guess, I didn't include that in my patch. Andy, can you make sure to change Template::Plugin::Date's version number for the next release? Ronald Tosh Cooey wrote: > Thanks Tom, this is what I was also thinking, but it just doesn't work, > '-1' keeps being returned. > > After digging into the source of the Date plugin: > http://cpansearch.perl.org/src/ABW/Template-Toolkit-2.20_4/lib/Template/Plugin/Date.pm > > The docs say: > # specify time as seconds since epoch > # or as a 'h:m:s d-m-y' or 'y-m-d h:m:s' string > [% date.format('4:20:36 21/12/2000') %] > [% date.format('2000/12/21 4:20:36') %] > > But neither of the above will work. This however does: > [% date.format('4:20:36 21-12-2000') %] > > So the solution to my problem is this monstrosity: > > [% formatted_date = record.0.timestamped.split(' ').1 _ ' ' _ > record.0.timestamped.split(' ').0.split('-').reverse.join('-') %] > > This will convert a MySQL date looking like this: > 2009-06-09 09:33:39 > > Into this: > 09:33:39 09-06-2009 > > Which can then be used as you indicated below: > > [% IF date.now - date.format(formatted_date, '%s') > 600 %] > ... > > Maybe somebody found something less fugly? > > Thanks everyone! > > Tosh > _______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
