Skip to content

Instantly share code, notes, and snippets.

@mugyu
Last active August 29, 2015 13:57
Show Gist options
  • Save mugyu/9540603 to your computer and use it in GitHub Desktop.
Save mugyu/9540603 to your computer and use it in GitHub Desktop.
Win32 FILETIMEとUNIX時間とを相互に変換する
# Win32 FILETIMEとUNIX時間とを相互に変換する
class Time
WINDOWS_TICK = 10000000
SEC_TO_UNIX_EPOCH = 11644473600
def self.at_wtime(wtime)
self.at(wtime / WINDOWS_TICK - SEC_TO_UNIX_EPOCH)
end
def to_wtime()
(self.to_i + SEC_TO_UNIX_EPOCH) * WINDOWS_TICK
end
end
puts hoge = Time.at_wtime(130324318525210430) #=> 2013-12-25 16:57:32 +0900
puts hoge.to_wtime # => 130324318520000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment