Skip to content

fix time_ns import error #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from bleak import discover
from asyncio import new_event_loop, set_event_loop, get_event_loop
from time import sleep, time_ns
from time import sleep
from binascii import hexlify
from json import dumps
from sys import argv
Expand All @@ -17,6 +17,15 @@


def get_best_result(device):
try:
from time import time_ns
except ImportError:
from datetime import datetime

def time_ns():
now = datetime.now()
return int(now.timestamp() * 1e9)

recent_beacons.append({
"time": time_ns(),
"device": device
Expand Down