def DatetimeToTimestamp(value):
 if value.tzinfo:
  value = value.astimezone(UTC)
 return (long((calendar.timegm(value.timetuple()) * 1000000L)) + value.microsecond)

def DatetimeToTimestamp ( value ) : if value . tzinfo : value = value . astimezone ( UTC ) return ( long ( ( calendar . timegm ( value . timetuple ( ) ) * 1000000 L ) ) + value . microsecond )
converts a datetime .