[Catalyst] Format last modified date field ...
J. Shirley
jshirley at gmail.com
Mon Dec 28 22:22:27 GMT 2009
On Mon, Dec 28, 2009 at 1:17 PM, Kiffin Gish <kiffin.gish at planet.nl> wrote:
> I'm using a last_modified field which is being displayed like this
> "2009-12-28T18:25:28" (what's that 'T' doing in there?) but want to use
> a different format, how?
>
> In the list.tt2 file for listing users, I have:
>
> [% WHILE (user = users_rs.next) -%]
> [% FOREACH col IN users_rs.result_source.columns -%]
> [% user.$col %]</td>
> [% END %]
> [% END -%]
>
> In the schema Users:
>
> __PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp",
> "Core");
> __PACKAGE__->table("users");
> __PACKAGE__->add_columns(
> ...
> "last_modified",
> {
> data_type => "DATETIME",
> default_value => undef,
> is_nullable => 1,
> size => undef,
> },
> );
>
> Thanks alot in advance.
>
>
> --
> Kiffin Gish <Kiffin.Gish at planet.nl>
> Gouda, The Netherlands
>
>
>
This recipe is a bit premature to release, and I've been meaning to
for a while but I am happy with it and it works well enough for me. I
had to rip out some other bits, so it may not compile right out.
I posted the gist here: http://gist.github.com/264994
The general idea is that in View::TT configuration, I define whatever
formats I want. Then in TT, if I have a date I just use the [%
date_whatever | date_long %]
Anything in the "date" group creates a filter called "date_long" or
"date_whatever".
I have used this to create a lot of various template filters that are
sourced by config, though.
Feedback welcome, I'll build a blog entry and cross-post to the wiki
after I clean it up.
-J
More information about the Catalyst
mailing list