Skip to content

Instantly share code, notes, and snippets.

@nowhereman
Created September 18, 2009 15:27
Show Gist options
  • Save nowhereman/189111 to your computer and use it in GitHub Desktop.
Save nowhereman/189111 to your computer and use it in GitHub Desktop.
Ruby Util - Convert Windows NT Epoch Timestamp to Unix Timestamp to Ruby Time
#Convert Windows NT Epoch Timestamp to Unix Timestamp to Ruby Time
begin
windows_time = (ARGV[0].to_i if ARGV[0]) || 128976739610612366 #default value
unix_time = windows_time/10000000-11644473600
ruby_time = Time.at(unix_time)
puts ruby_time.strftime("le %d/%m/%Y à %H:%M:%S GMT %z")#French date format
unix_time2 = ruby_time.to_i
puts "Unix time: #{unix_time}"
windows_time2 = (unix_time2 + 11644473600) * 10000000
puts "Windows time: #{windows_time2}"
rescue Exception => e
puts "error: #{e.message}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment