Last active
August 29, 2015 13:57
-
-
Save mugyu/9540603 to your computer and use it in GitHub Desktop.
Win32 FILETIMEとUNIX時間とを相互に変換する
This file contains hidden or 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
# 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