Tosh Cooey wrote:
[SNIP]
> [% formatted_date = record.0.timestamped.split(' ').1 _ ' ' _
> record.0.timestamped.split(' ').0.split('-').reverse.join('-') %]
[SNIP]
> Maybe somebody found something less fugly?
A couple of suggestions:
*) Submit a patch that fixes the Date plugin formatting to work correctly. Make
sure you are using the latest version. It looks like the latest email to the
list claims that it works in the newest one.
*) Use the replace vmethod instead of a ton of splits/reverses:
ie: [% record.0.replace('(2009)-(06)-(09) (09):(33):(39)', '$4:$5:$6
$3-$2-$1'); %]
*) Use a module like Date::Parse and pass a method to access it via the vars.
$vars =
{
api => {
date_parse => sub {
my $v = shift;
return Date::Parse::str2time($v);
},
}
}
Then you can call like: api.date_parse(). Might be wise to put it under its own
section in your "api". Like api.time.date_parse() or api.time.parse().
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates