Commit | Line | Data |
7adfd53f |
1 | package Reaction::UI::ViewPort::Field::DateTime; |
2 | |
1734a92a |
3 | use Scalar::Util 'blessed'; |
7adfd53f |
4 | use Reaction::Class; |
586b1b0d |
5 | use Reaction::Types::DateTime (); |
ddccc6a2 |
6 | use aliased 'Reaction::UI::ViewPort::Field'; |
7adfd53f |
7 | |
81393881 |
8 | use namespace::clean -except => [ qw(meta) ]; |
9 | extends Field; |
6ab43711 |
10 | |
6ab43711 |
11 | |
81393881 |
12 | has '+value' => (isa => Reaction::Types::DateTime::DateTime()); |
6ab43711 |
13 | |
81393881 |
14 | has value_string_default_format => ( |
15 | isa => 'Str', is => 'rw', required => 1, default => sub { "%F %H:%M:%S" } |
16 | ); |
17 | |
18 | around _value_string_from_value => sub { |
19 | my $orig = shift; |
20 | my $self = shift; |
21 | my $format = $self->value_string_default_format; |
22 | return $self->$orig(@_)->strftime($format); |
7adfd53f |
23 | }; |
24 | |
81393881 |
25 | __PACKAGE__->meta->make_immutable; |
26 | |
27 | |
6ab43711 |
28 | 1; |