On Thu, Nov 3, 2011 at 6:55 AM, Kieren Diment <[email protected]> wrote:
> On 03/11/2011, at 9:40 PM, Adam Jimerson wrote:
>
> > The problem I see with doing it this way: $formatted_date_string =
> > $c->model('DB::TableName')->find($row_index)->date_field->mdy('/'); is
> > that It looks like I would
> > have to do this every time I grab a date from the database. That is fine
> > but there are times in my app where I pull everything from the database
> to
> > display like so:
> >
> > my $things = $c->stash->{mydata_rs}->search(
> > undef,
> > {
> > order_by => { -asc => 'uniq' },
> > },
> > );
> >
>
>
> One option is to define a method in whatever Result class mydata_rs
> produces:
>
> sub my_date_format {
> my $self = shift;
> return $self->date_field->mdy('/');
> }
>
>
> then in your template:
>
> [% WHILE (row = mydata_rs.next); row.my_date_format ; END %]
>
> or you can just call the datetime methods in the template:
>
> [% WHILE (row = mydata_rs.next); row.my_date_field.ymd('/') ; END %]
>
>
So if I go the latter route and call it from the template I won't have to
use a sub like that to do the formatting correct? Also would it accept a
ymd hms format or do they have to be separate?
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/