aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-100/lubos-kolouch/perl/ch-1.pl35
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;