the fastest code is that which does not exist
parent
fcc38b75bf
commit
d3e6e93d6a
|
@ -30,30 +30,5 @@ module Rex
|
|||
|
||||
str.empty? ? "0 secs" : str.strip
|
||||
end
|
||||
|
||||
#
|
||||
# Converts a string in the form n years g days x hours y mins z secs.
|
||||
#
|
||||
def self.str_to_sec(str)
|
||||
fields = str.split
|
||||
secs = 0
|
||||
|
||||
fields.each_with_index do |f, idx|
|
||||
case f
|
||||
when 'year', 'years'
|
||||
secs += 31536000 * fields[idx - 1].to_i
|
||||
when 'day', 'days'
|
||||
secs += 86400 * fields[idx - 1].to_i
|
||||
when 'hour', 'hours'
|
||||
secs += 3600 * fields[idx - 1].to_i
|
||||
when 'min', 'mins'
|
||||
secs += 60 * fields[idx - 1].to_i
|
||||
when 'sec', 'secs'
|
||||
secs += 1 * fields[idx - 1].to_i
|
||||
end
|
||||
end
|
||||
|
||||
secs
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue