# -*- coding: binary -*-1module Rex2###3#4# Extended time related functions.5#6###7module ExtTime8#9# Convert seconds to a string that is broken down into years, days, hours,10# minutes, and second.11#12def self.sec_to_s(seconds)13return "0 secs" if seconds.to_i <= 014[[31536000, 'year'], [86400, 'day'], [3600, 'hour'], [60, 'min'], [1, 'sec']].map! { |count, name|15if (c = seconds / count) > 016c = c.truncate17seconds -= c * count18if c == 119"#{c} #{name}"20elsif c > 121"#{c} #{name}s"22end23end24}.compact.join(' ')25end26end27end282930