Mine (Only tested on a couple of Linux boxes):


if `uptime`.include? "day"
  puts(Time.now - ((`uptime`.split[2].to_i * 1440) + (`uptime`.split[4].split(":")[0].to_i * 60) + (`uptime`.split[4].split(":")[1].to_i)) * 60)
elsif `uptime`.include? "min"
  puts(Time.now - `uptime`.split[2].split(":")[0].to_i * 60)
else
  puts(Time.now - (`uptime`.split[2].split(":")[0].to_i * 60) + (`uptime`.split[2].split(":")[1].to_i))
end

On Tue, Aug 26, 2008 at 01:30:50AM +0900, Eric I. wrote:
> 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 !
> 

-- 
nathan
nathan_at_nathanpowell_dot_org

To give anything less than your best is to sacrifice the gift.
		 ~ Steve Prefontaine
------------------------------------