NAME DBIx::Class::InflateColumn::TimeMoment - Auto-create TimeMoment objects from date and datetime columns. VERSION version 0.01 SYNOPSIS Load this component and then declare one or more columns to be of the datetime, timestamp or date datatype. package Event; use base 'DBIx::Class::Core'; __PACKAGE__->load_components(qw/InflateColumn::TimeMoment/); __PACKAGE__->add_columns( starts_when => { data_type => 'datetime' } create_date => { data_type => 'date' } ); Then you can treat the specified column as a TimeMoment object. print "This event starts the month of ". $event->starts_when->strftime('%B'); If you want to inflate no matter what data_type your column is, use inflate_datetime or inflate_date: __PACKAGE__->add_columns( starts_when => { data_type => 'varchar', inflate_datetime => 1 } ); __PACKAGE__->add_columns( starts_when => { data_type => 'varchar', inflate_date => 1 } ); It's also possible to explicitly skip inflation: __PACKAGE__->add_columns( starts_when => { data_type => 'datetime', inflate_datetime => 0 } ); NOTE: Don't rely on InflateColumn::TimeMoment to parse date strings for you. The column is set directly for any non-references and InflateColumn::TimeMoment is completely bypassed. Instead, use an input parser to create a TimeMoment object. DESCRIPTION This module works with Time::Moment IS8601 date formats to inflate/deflate. A later version may handle databases in a more forgiving way, but really why not make them do something sensible. For more help with using components, see "USING" in DBIx::Class::Manual::Component. register_column Chains with the "register_column" in DBIx::Class::Row method, and sets up datetime columns appropriately. This would not normally be directly called by end users. In the case of an invalid date, Time::Moment will throw an exception. To bypass these exceptions and just have the inflation return undef, use the datetime_undef_if_invalid option in the column info: "broken_date", { data_type => "datetime", default_value => '0000-00-00', is_nullable => 1, datetime_undef_if_invalid => 1 } HISTORY As is obvious from a quick inspection of the code, this module is very heavily based on and draws code from DBIx::Class::InflateColumn::DateTime, however it is significantly simplified due to the less well developed timezone handling and formatter ecosystem. SEE ALSO More information about the add_columns method, and column metadata, can be found in the documentation for DBIx::Class::ResultSource. FURTHER QUESTIONS? Check the list of additional DBIC resources. INSTALLATION See perlmodinstall for information and options on installing Perl modules. BUGS AND LIMITATIONS You can make new bug reports, and view existing ones, through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=DBIx-Class-InflateColu mn-TimeMoment. AVAILABILITY The project homepage is https://metacpan.org/release/DBIx-Class-InflateColumn-TimeMoment. The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/DBIx::Class::InflateColumn::TimeMoment/. AUTHOR Nigel Metheringham COPYRIGHT AND LICENSE This software is copyright (c) 2015 by Nigel Metheringham. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.