Commits

Shlomi Fish committed 90e7da4

Add support for 1h.

  • Participants
  • Parent commits 4438d65

Comments (0)

Files changed (2)

File App-Countdown/lib/App/Countdown.pm

 sub _calc_delay {
     my ($self, $delay_spec) = @_;
 
-    if (my ($n, $qualifier) = $delay_spec =~ /\A([1-9][0-9]*)([m]?)\z/)
+    if (my ($n, $qualifier) = $delay_spec =~ /\A([1-9][0-9]*)([mh]?)\z/)
     {
-        return ($n * ($qualifier eq 'm' ? 60 : 1));
+        return ($n * ($qualifier eq 'h'
+                ? (60 * 60)
+                : $qualifier eq 'm'
+                ? 60
+                : 1
+            )
+        );
     }
     else
     {

File App-Countdown/t/unit-calc-delay.t

 use strict;
 use warnings;
 
-use Test::More tests => 4;
+use Test::More tests => 5;
 
 use App::Countdown;
 
 
     # TEST
     is ($obj->_calc_delay('1m'), 60, "_calc_delay(1m) == 60 (1 minute)");
+
+    # TEST
+    is ($obj->_calc_delay('1h'), 60*60, "_calc_delay(1h) == 60*60 (1 hour)");
 }