Skip to content

Commit

Permalink
Fix code for avoid the warning message at issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
azumakuniyuki committed Mar 10, 2015
1 parent ee4277e commit fe3d02d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/sisimai/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,16 @@ def to_second( argvs )
return 0 unless argvs.kind_of?(String)

getseconds = 0
unitoftime = @@TimeUnit.keys
mathconsts = @@MathematicalConstant.keys
unitoftime = @@TimeUnit.keys.join
mathconsts = @@MathematicalConstant.keys.join

if vm = argvs.match(/\A(\d+|\d+[.]\d+)(#{unitoftime})?\z/) then
if vm = argvs.match(/\A(\d+|\d+[.]\d+)([#{unitoftime}])?\z/) then
# 1d, 1.5w
n = vm[1].to_f
u = vm[2] || 'd'
getseconds = n * @@TimeUnit[ u ].to_f

elsif vm = argvs.match(/\A(\d+|\d+[.]\d+)?(#{mathconsts})(#{unitoftime})?\z/) then
elsif vm = argvs.match(/\A(\d+|\d+[.]\d+)?([#{mathconsts}])([#{unitoftime}])?\z/) then
# 1pd, 1.5pw
n = vm[1].to_f || 1
n = 1 if n.to_i == 0
Expand Down

0 comments on commit fe3d02d

Please sign in to comment.