from datetime import datetime
import math


def InternalTimeFromPyTime(pytime):
  """Returns a Chromium internal time value representing a Python datetime."""
  # Microseconds since 1601-01-01 00:00:00 UTC
  delta = pytime - datetime(1601, 1, 1)
  return math.trunc(delta.total_seconds()) * 1000000 + delta.microseconds