Re: [Catalyst] Changing format of date field
On Mon, Jan 6, 2014 at 7:18 AM, Adam Witney 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 -MM-DD format. > > I can modify this to DD/MM/ 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/
Re: [Catalyst] Changing format of date field
DateTime has an option to change the default stringification with a 'formatter' option. Also DBIx::Class::InflateColumn::DateTime is a convenience method, you could choose to use the DBIx::Class::InflateColumn yourself and combine this with the DateTime formatter option to give you the result you are looking for. icydee On 6 January 2014 15:18, Adam Witney 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 -MM-DD format. > > I can modify this to DD/MM/ 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. > > Thanks > > Adam > > ___ > 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/ > ___ 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/
[Catalyst] Changing format of date field
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 -MM-DD format. I can modify this to DD/MM/ 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. Thanks Adam ___ 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/