package MY::CLI::Command::Date; use strict; use warnings; use MY::CLI -command; use Time::Piece; sub abstract { return "Give information about a date"; } sub usage_desc { return "cli.pl Date --date "; } sub opt_spec { return ( [ 'date=s', 'A date you want information about' ], ); } sub validate_args {} sub execute { my ($self, $opt, $args) = @_; if ( !$opt->{date} ) { print $self->usage->text; return; } my $time = Time::Piece->strptime( $opt->{date}, '%Y-%m-%d' ); print sprintf "Datum: %s KW: %s Schaltjahr: %s\n", $time->dmy('.'), $time->week, $time->is_leap_year; } 1;