Skip to content

Instantly share code, notes, and snippets.

@axic
Created October 6, 2010 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axic/614050 to your computer and use it in GitHub Desktop.
Save axic/614050 to your computer and use it in GitHub Desktop.
Turn the Linux kernel timestamp (from dmesg) into a date
input = ARGV.to_s.match(/^\[?([\d.]+)\]?/)
input = input[1] if input
uptime = File.new("/proc/uptime").gets
uptime = uptime.match(/^([\d.]+)/).to_a.first if uptime
if input and uptime then
puts(Time.now - uptime.to_f + input.to_f)
else
puts "unable to parse"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment