summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZack Hobson2009-08-23 21:22:04 -0700
committerZack Hobson2009-08-23 21:22:04 -0700
commit3cb1969adcb82a81458b474c350d6045626d4ac2 (patch)
treedda7352de1d287981b06001204c6418eb3dd82a3
parentd82f777ee4e3e89cfab56afb92297a6330dd8199 (diff)
downloadhcl-3cb1969adcb82a81458b474c350d6045626d4ac2.tar.bz2
Allow start +decimal input without a dot, closes #29.
-rw-r--r--CHANGELOG2
-rw-r--r--lib/hcl/commands.rb2
-rw-r--r--lib/hcl/utility.rb2
-rw-r--r--test/utility_test.rb17
4 files changed, 20 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e0c984a..ca4adca 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,6 @@
= Recent Changes in HCl
-* Reverted: Adding note fails when task is started without notes, reopens #26.
+* Reverted and re-fixed: Adding note fails when task is started without notes, #26.
* Reinstate the --version option
== v0.2.2 Sun Aug 9 11:16:34 2009 -0700
diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb
index 5bc564f..fcf6939 100644
--- a/lib/hcl/commands.rb
+++ b/lib/hcl/commands.rb
@@ -34,7 +34,7 @@ module HCl
end
def start *args
- starting_time = args.detect {|x| x =~ /^\+\d*(\.|:)\d+$/ }
+ starting_time = args.detect {|x| x =~ /^\+\d*(\.|:)?\d+$/ }
if starting_time
args.delete(starting_time)
starting_time = time2float starting_time
diff --git a/lib/hcl/utility.rb b/lib/hcl/utility.rb
index bbd5065..7cf1bfb 100644
--- a/lib/hcl/utility.rb
+++ b/lib/hcl/utility.rb
@@ -17,7 +17,7 @@ module HCl
if time_string =~ /:/
hours, minutes = time_string.split(':')
hours.to_f + (minutes.to_f / 60.0)
- elsif time_string =~ /./
+ else
time_string.to_f
end
end
diff --git a/test/utility_test.rb b/test/utility_test.rb
new file mode 100644
index 0000000..1435d97
--- /dev/null
+++ b/test/utility_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class UtilityTest < Test::Unit::TestCase
+ include HCl::Utility
+
+ should "convert decimal input when converting time2float" do
+ assert_equal 2.5, time2float("2.5")
+ end
+
+ should "convert HH:MM input when converting time2float" do
+ assert_equal 2.5, time2float("2:30")
+ end
+
+ should "assume decimal input when converting time2float" do
+ assert_equal 2.0, time2float("2")
+ end
+end