Created
May 29, 2012 21:33
-
-
Save chancancode/2830878 to your computer and use it in GitHub Desktop.
Ruby time to .NET ticks
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
class Time | |
# See http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx | |
TICKS_SINCE_EPOCH = Time.utc(0001,01,01).to_i * 10000000 | |
def ticks | |
to_i * 10000000 + nsec / 100 - TICKS_SINCE_EPOCH | |
end | |
end |
Any improvements required for Ruby 2.5?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
did some updates for 1.8.7, added some description for myself but maybe it would help somebody else https://gist.github.com/morkevicius/10549920