hiddenarray needed to be moved to field::mutable. should we discontinue this field?
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Field / Mutable / DateTime.pm
CommitLineData
ddccc6a2 1package Reaction::UI::ViewPort::Field::Mutable::DateTime;
2
3use Reaction::Class;
4use Time::ParseDate;
5use DateTime;
6
36d54b14 7class 'Reaction::UI::ViewPort::Field::Mutable::DateTime',
8 is 'Reaction::UI::ViewPort::Field::DateTime', which {
ddccc6a2 9
62ffa273 10 does 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple';
6a531d96 11
ddccc6a2 12 implements adopt_value_string => as {
13 my ($self) = @_;
14 my $value = $self->value_string;
15 my ($epoch) = Time::ParseDate::parsedate($value);
16 if (defined $epoch) {
17 my $dt = 'DateTime'->from_epoch( epoch => $epoch );
18 $self->value($dt);
19 } else {
20 $self->message("Could not parse date or time");
ddccc6a2 21 }
22 };
23
ddccc6a2 24};
25
261;
27
28
29=head1 NAME
30
31Reaction::UI::ViewPort::Field::DateTime
32
33=head1 DESCRIPTION
34
35=head1 METHODS
36
37=head2 value_string
38
39Accessor for the string representation of the DateTime object.
40
41=head2 value_string_default_format
42
43By default it is set to "%F %H:%M:%S".
44
45=head1 SEE ALSO
46
47=head2 L<DateTime>
48
49=head2 L<Reaction::UI::ViewPort::Field>
50
51=head1 AUTHORS
52
53See L<Reaction::Class> for authors.
54
55=head1 LICENSE
56
57See L<Reaction::Class> for the license.
58
59=cut