1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

python:nt_time: Add NT_TIME_MAX constant

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Jo Sutton 2024-04-05 13:43:46 +13:00 committed by Andrew Bartlett
parent c6ed19ad1a
commit 42710f0455

View File

@ -25,6 +25,7 @@ import re
NtTime = NewType("NtTime", int)
NtTimeDelta = NewType("NtTimeDelta", int)
NT_TIME_MAX = NtTime((1 << 64) - 1)
NT_EPOCH = datetime.datetime(1601, 1, 1, 0, 0, 0, 0, tzinfo=datetime.timezone.utc)
NT_TICKS_PER_μSEC = 10
@ -34,7 +35,7 @@ NT_TICKS_PER_SEC = NT_TICKS_PER_μSEC * 1_000_000
def _validate_nt_time(nt_time: NtTime) -> None:
if not isinstance(nt_time, int):
raise ValueError(f"{nt_time} is not an integer")
if not 0 <= nt_time < 2**64:
if not 0 <= nt_time <= NT_TIME_MAX:
raise ValueError(f"{nt_time} is out of range")