[Dbix-class] InflateColumn::DateTime - how to use it?
Adam Herzog
adam at herzogdesigns.com
Thu May 10 13:40:52 GMT 2007
On May 10, 2007, at 8:17 AM, RA Jones wrote:
> __PACKAGE__->load_components(qw/PK::Auto Core
> InflateColumn::DateTime/);
I think InflateColumn::DateTime probably has to be _before_ Core:
__PACKAGE__->load_components(qw/InflateColumn::DateTime Core/);
Note also that PK::Auto is included in 'Core', so you don't have to
specify it.
> On reflection though, maybe InflateColumn is not the correct method
> for what I really want - to globally reformat date fields to EU
> format.
If you're certain you'll only want an EU formatted date, you can use
DBIx::Class::InflateColumn in your resultset and add the code to
inflate to whatever you'd like. Check the InflateColumn docs for an
example.
I generally prefer receiving the DateTime object, though, since my
formatting is usually dependent on what I'm doing with the data. If
you're using something like Catalyst, I'd pass the DateTime object
down to the view, and let it decide how to format it.
-A
More information about the Dbix-class
mailing list