| 1 | package DBIx::Class::AsFdat; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use base 'DBIx::Class'; | ||
| 5 | use Scalar::Util qw/blessed/; | ||
| 6 | |||
| 7 | our $VERSION = '0.03'; | ||
| 8 | |||
| 9 | sub as_fdat { | ||
| 10 | my $self = shift; | ||
| 11 | |||
| 12 | my $fdat; | ||
| 13 | for my $column ($self->result_source->columns) { | ||
| 14 | $fdat->{$column} = $self->$column; | ||
| 15 | |||
| 16 | # inflate the datetime | ||
| 17 | if (blessed $fdat->{$column} and $fdat->{$column}->isa('DateTime')) { | ||
| 18 | for my $type (qw(year month day hour minute second)) { | ||
| 19 | $fdat->{"${column}_$type"} = $fdat->{$column}->$type; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | } | ||
| 23 | return $fdat; | ||
| 24 | } | ||
| 25 | |||
| 26 | 1; | ||
| 27 | __END__ |