Last active
December 10, 2015 05:28
-
-
Save hattorix/4388057 to your computer and use it in GitHub Desktop.
.NET の DateTime.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
def get_ticks(date): | |
unix_time = datetime(1, 1, 1) | |
delta = date - unix_time | |
return int(delta.total_seconds() * 10000000) + (delta.microseconds * 10) | |
def ticks_to_date(ticks): | |
delta = timedelta(microseconds=ticks / 10) | |
return datetime(1, 1, 1) + delta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment