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 (); |
7adfd53f | 6 | |
81393881 | 7 | use namespace::clean -except => [ qw(meta) ]; |
7b5e71ad | 8 | extends 'Reaction::UI::ViewPort::Field'; |
6ab43711 | 9 | |
7b5e71ad | 10 | use MooseX::Types::Moose qw/Str/; |
6ab43711 | 11 | |
81393881 | 12 | has '+value' => (isa => Reaction::Types::DateTime::DateTime()); |
6ab43711 | 13 | |
81393881 | 14 | has value_string_default_format => ( |
7b5e71ad | 15 | isa => Str, is => 'rw', required => 1, default => sub { "%F %H:%M:%S" } |
81393881 | 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; |