On Mon, Jan 6, 2014 at 7:18 AM, Adam Witney <awit...@sgul.ac.uk> wrote:
> Hi, > > I have a date field in a DBIx::Class Result class using > InflateColumn::DateTime. When I pass this through a Catalyst/TT > application, the date is presented in YYYY-MM-DD format. > > I can modify this to DD/MM/YYYY in my TT template with object.dmy('/'), > but I would prefer to change the default DateTime stringification, however > I am not quite sure where or how to do this? > > Any ideas greatly appreciated. > Seem like formatting in the template is the right place -- may want to have different formats in different places in your app. Then you might also think about how best to localize. One idea is to localize a set of names for a set of formats: [% dt_fmt = c.localize( '_DT_DATE_ONLY' ); foo.some_dt_object.strftime( dt_fmt ) | html %] I have also used a function that does the above, but also clones and sets the time zone and locale based on the user's preferences: [% user_time( foo.event_start, '_DT_TIMESTAMP_WITH_ZONE' ) | html %] -- Bill Moseley mose...@hank.org
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/