8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/kanrisuru/core/system/parsers/uptime.rb', line 8
def self.parse(command)
seconds = command.to_s.split[0].to_i
minutes = seconds / 60
hours = seconds / 3600
days = seconds / 86_400
seconds_dur = seconds
days_dur = seconds_dur / 86_400
seconds_dur -= days_dur * 86_400
hours_dur = seconds_dur / 3600
seconds_dur -= hours_dur * 3600
minutes_dur = seconds_dur / 60
seconds_dur -= minutes_dur * 60
uptime_s = "#{days_dur}:#{hours_dur}:#{minutes_dur}:#{seconds_dur}"
boot_time = Time.now - seconds
Kanrisuru::Core::System::Uptime.new(
boot_time,
uptime_s,
seconds,
minutes,
hours,
days
)
end
|