Skip to content

Commit

Permalink
add reader for datetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrockway committed Sep 22, 2008
1 parent 30955d8 commit 54dfcbd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -5,6 +5,7 @@ all_from 'lib/Ernst.pm';

requires 'Data::Thunk';
requires 'DateTime';
requires 'DateTime::Format::DateParse';
requires 'DateTime::Format::Strptime';
requires 'List::MoreUtils';
requires 'Module::Pluggable::Object';
Expand Down
20 changes: 18 additions & 2 deletions lib/Ernst/Description/DateTime.pm
@@ -1,11 +1,13 @@
package Ernst::Description::DateTime;
use Moose;
use DateTime::Format::Strptime;
use DateTime;
use DateTime::Format::Strptime;
use DateTime::Format::DateParse;

extends 'Ernst::Description::Value';

with 'Ernst::Description::Trait::PostProcess';
with 'Ernst::Description::Trait::PostProcess',
'Ernst::Description::Trait::Transform';

has 'format' => (
is => 'ro',
Expand Down Expand Up @@ -33,4 +35,18 @@ has '+postprocess' => (
},
);

has '+transform_source' => (
lazy => 1,
default => sub { [shift->name] },
);

has '+transform_rule' => (
lazy => 1,
default => sub {
sub {
DateTime::Format::DateParse->parse_datetime($_[0]);
},
},
);

1;

0 comments on commit 54dfcbd

Please sign in to comment.