Created
September 18, 2009 15:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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