diff --git a/lib/NGCP/Panel/Field/DateTime.pm b/lib/NGCP/Panel/Field/DateTime.pm new file mode 100644 index 0000000000..cde53a6994 --- /dev/null +++ b/lib/NGCP/Panel/Field/DateTime.pm @@ -0,0 +1,37 @@ +package NGCP::Panel::Field::DateTime; +use HTML::FormHandler::Moose; +use Sipwise::Base; +extends 'HTML::FormHandler::Field::Text'; + +has '+deflate_method' => ( default => sub { \&datetime_deflate } ); + +sub datetime_deflate { + my ( $self, $value ) = @_; + if(blessed($value) && $value->isa('DateTime')) { + return $value->ymd('-') . ' ' . $value->hms(':');; + } else { + return $value; + } +} + +1; + +=head1 NAME + +NGCP::Panel::Field::DateTime + +=head1 DESCRIPTION + + +=head1 AUTHOR + +Gerhard Jungwirth + +=head1 LICENSE + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Form/BillingPeaktimeSpecial.pm b/lib/NGCP/Panel/Form/BillingPeaktimeSpecial.pm index 9d7964bf0d..7c8f32704a 100644 --- a/lib/NGCP/Panel/Form/BillingPeaktimeSpecial.pm +++ b/lib/NGCP/Panel/Form/BillingPeaktimeSpecial.pm @@ -15,7 +15,7 @@ sub build_render_list {[qw/submitid fields actions/]} sub build_form_element_class { [qw/form-horizontal/] } has_field 'start' => ( - type => 'Text', + type => '+NGCP::Panel::Field::DateTime', element_attr => { rel => ['tooltip'], title => ['YYYY-MM-DD HH:mm:ss'] @@ -25,7 +25,7 @@ has_field 'start' => ( ); has_field 'end' => ( - type => 'Text', + type => '+NGCP::Panel::Field::DateTime', element_attr => { rel => ['tooltip'], title => ['YYYY-MM-DD HH:mm:ss']