From c37010448433854ae8d4721fe66e3956a05a7f5b Mon Sep 17 00:00:00 2001 From: Peter Babics Date: Mon, 14 Feb 2022 10:45:11 +0100 Subject: [PATCH] Fix time cut-off on time_ns --- freezegun/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freezegun/api.py b/freezegun/api.py index 81d4da17..62522a85 100644 --- a/freezegun/api.py +++ b/freezegun/api.py @@ -180,7 +180,8 @@ def fake_time(): def fake_time_ns(): if _should_use_real_time(): return real_time_ns() - return int(int(fake_time()) * 1e9) + current_time = get_current_time() + return int(calendar.timegm(current_time.timetuple()) * 1_000_000_000 + current_time.microsecond * 1_000) def fake_localtime(t=None):