diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2021-02-20 10:34:08 +0100 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2021-02-20 10:34:08 +0100 |
| commit | 0682fba9a2de1142ff281c93ca066abc090c2ecc (patch) | |
| tree | 1e840444d8409cb424a7c41e021a989aa41cc9bb | |
| parent | ac1ff7d7ab517d6138567eb9930592e90efd35fc (diff) | |
| download | perlweeklychallenge-club-0682fba9a2de1142ff281c93ca066abc090c2ecc.tar.gz perlweeklychallenge-club-0682fba9a2de1142ff281c93ca066abc090c2ecc.tar.bz2 perlweeklychallenge-club-0682fba9a2de1142ff281c93ca066abc090c2ecc.zip | |
PWC 100 Task 1 Perl LK
| -rw-r--r-- | challenge-100/lubos-kolouch/perl/ch-1.pl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-100/lubos-kolouch/perl/ch-1.pl b/challenge-100/lubos-kolouch/perl/ch-1.pl new file mode 100644 index 0000000000..06b2962ba7 --- /dev/null +++ b/challenge-100/lubos-kolouch/perl/ch-1.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl +#=============================================================================== +# +# FILE: ch-1.pl +# +# USAGE: ./ch-1.pl +# +# DESCRIPTION: Perl Weekly Challenge #100 +# Task 1 +# AUTHOR: Lubos Kolouch +# CREATED: 02/20/2021 10:16:51 AM +#=============================================================================== + +use strict; +use warnings; +use DateTime::Format::DateParse; + +sub convert_time { + my $what = shift; + + my $pattern = $what =~ /m/ ? '%H:%M' : '%I:%M %P'; + + return DateTime::Format::DateParse + -> parse_datetime($what) + -> strftime($pattern); + +} + +use Test::More; + +is(convert_time('05:15pm'), '17:15'); +is(convert_time('05:15 pm'), '17:15'); +is(convert_time('19:15'), '07:15 pm'); + +done_testing; |
