r20898@agaton (orig r755): wreis | 2008-07-24 00:32:56 +0100
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Field / DateTime.pm
CommitLineData
7adfd53f 1package Reaction::UI::ViewPort::Field::DateTime;
2
1734a92a 3use Scalar::Util 'blessed';
7adfd53f 4use Reaction::Class;
586b1b0d 5use Reaction::Types::DateTime ();
ddccc6a2 6use aliased 'Reaction::UI::ViewPort::Field';
7adfd53f 7
ddccc6a2 8class DateTime is Field, which {
586b1b0d 9 has '+value' => (isa => Reaction::Types::DateTime::DateTime());
6ab43711 10
7adfd53f 11 has value_string_default_format => (
12 isa => 'Str', is => 'rw', required => 1, default => sub { "%F %H:%M:%S" }
13 );
6ab43711 14
656d19e9 15 around _value_string_from_value => sub {
16 my $orig = shift;
7adfd53f 17 my $self = shift;
6ab43711 18 my $format = $self->value_string_default_format;
656d19e9 19 return $self->$orig(@_)->strftime($format);
7adfd53f 20 };
6ab43711 21
7adfd53f 22};
23
6ab43711 241;