Skip to content

Instantly share code, notes, and snippets.

@hattorix
Last active December 10, 2015 05:28
Show Gist options
  • Save hattorix/4388057 to your computer and use it in GitHub Desktop.
Save hattorix/4388057 to your computer and use it in GitHub Desktop.
.NET の DateTime.Ticks と同等の数値を取得する関数
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