My solution:
====
SecsPerMinute = 60
SecsPerHour = 60*SecsPerMinute
SecsPerDay = 24*SecsPerHour
match = /up (\d+) days, (\d+):(\d+),/.match %x{uptime}
# extract data from reg. exp. and convert to integers
days, hours, minutes = *((1..3).map { |index| match[index].to_i })
now = Time.now
now -= now.sec # normalize to 0 seconds into the current minute
boot_time = now - days*SecsPerDay - hours*SecsPerHour -
minutes*SecsPerMinute
boot_time_s = boot_time.strftime("%a %b %e %l:%M %p")
puts "Machine last booted: #{boot_time_s} (+/- 1 minute)."
====
Eric
====
On-site, hands-on Ruby and Ruby on Rails training is
available from http://LearnRuby.com !