/
githubmirror
/
metasploit-framework
Обзор
Документация
Войти
/
githubmirror
/
metasploit-framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lib/rex/ext_time.rb
28 строк
667 B
dwelch-r7
Zeitwerk `rex` folder
08 фев 2021, 15:24
08 фев 2021, 15:24
b95be3e
Код
Авторство
О чём код?
# -*- coding: binary -*- module Rex ### # # Extended time related functions. # ### module ExtTime # # Convert seconds to a string that is broken down into years, days, hours, # minutes, and second. # def self.sec_to_s(seconds) return "0 secs" if seconds.to_i <= 0 [[31536000, 'year'], [86400, 'day'], [3600, 'hour'], [60, 'min'], [1, 'sec']].map! { |count, name| if (c = seconds / count) > 0 c = c.truncate seconds -= c * count if c == 1 "#{c} #{name}" elsif c > 1 "#{c} #{name}s" end end }.compact.join(' ') end end end