aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Field/DateTime.pm
blob: 50d26cf1789064a6290a05be227aa516e6b96f43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package Reaction::UI::ViewPort::Field::DateTime;

use Scalar::Util 'blessed';
use Reaction::Class;
use Reaction::Types::DateTime;
use aliased 'Reaction::UI::ViewPort::Field';

class DateTime is Field, which {
  has '+value' => (isa => DateTime);

  has value_string_default_format => (
    isa => 'Str', is => 'rw', required => 1, default => sub { "%F %H:%M:%S" }
  );

  around _value_string_from_value => sub {
    my $orig = shift;
    my $self = shift;
    my $format = $self->value_string_default_format;
    return $self->$orig(@_)->strftime($format);
  };

};

1;