| 1 | package DBIx::Class::Schema::PopulateMore::Inflator::Date; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use DateTimeX::Easy; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | extends 'DBIx::Class::Schema::PopulateMore::Inflator'; | |||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | DBIx::Class::Schema::PopulateMore::Inflator::Date - Returns A L<DateTime> object | ||||||||||
| 10 | |||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||
| 12 | |||||||||||
| 13 | Sometimes you need to put dates into your table rows, but this can be a big | ||||||||||
| 14 | hassle to do, particularly in a crossplatform way. This plugin will assist | ||||||||||
| 15 | in this. It also makes it easy to insert relative date/times. such as 'now', | ||||||||||
| 16 | 'last week', etc. See L<DateTimeX::Easy> for more information on how we | ||||||||||
| 17 | coerce dates. | ||||||||||
| 18 | |||||||||||
| 19 | =head1 ATTRIBUTES | ||||||||||
| 20 | |||||||||||
| 21 | This class defines the following attributes. | ||||||||||
| 22 | |||||||||||
| 23 | =head1 METHODS | ||||||||||
| 24 | |||||||||||
| 25 | This module defines the following methods. | ||||||||||
| 26 | |||||||||||
| 27 | =head2 inflate($command, $string) | ||||||||||
| 28 | |||||||||||
| 29 | This is called by Populate's dispatcher, when there is a match. | ||||||||||
| 30 | |||||||||||
| 31 | =cut | ||||||||||
| 32 | |||||||||||
| 33 | sub inflate | ||||||||||
| 34 | { | ||||||||||
| 35 | 4 | ▶ | my ($self, $command, $string) = @_; | ||||||||
|
Subroutine
inflate: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 36 | |||||||||||
| 37 | 4 | ▶ | if(my $dt = DateTimeX::Easy->new($string, default_time_zone=>'UTC')) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | { | ||||||||||
| 39 | 4 | return $dt; | |||||||||
| 40 | } | ||||||||||
| 41 | else | ||||||||||
| 42 | { | ||||||||||
| 43 | 0 | $command->exception_cb->("Couldn't deal with $string as a date"); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | =head1 AUTHOR | ||||||||||
| 49 | |||||||||||
| 50 | Please see L<DBIx::Class::Schema::PopulateMore> For authorship information | ||||||||||
| 51 | |||||||||||
| 52 | =head1 LICENSE | ||||||||||
| 53 | |||||||||||
| 54 | Please see L<DBIx::Class::Schema::PopulateMore> For licensing terms. | ||||||||||
| 55 | |||||||||||
| 56 | =cut | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | 3 | 1; | |||||||||