From 2c48e90fad04db6a78fc4dc1f2cb12154db7f711 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Thu, 19 Nov 2020 11:20:35 +1300 Subject: [PATCH] samba-tool pso uses common timestamp functions Signed-off-by: Douglas Bagnall Reviewed-by: Noel Power --- python/samba/netcmd/pso.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/python/samba/netcmd/pso.py b/python/samba/netcmd/pso.py index 200b6ff2a9e..d260e3bd406 100644 --- a/python/samba/netcmd/pso.py +++ b/python/samba/netcmd/pso.py @@ -22,30 +22,15 @@ from samba.netcmd import (Command, CommandError, Option, SuperCommand) from samba.dcerpc.samr import (DOMAIN_PASSWORD_COMPLEX, DOMAIN_PASSWORD_STORE_CLEARTEXT) from samba.auth import system_session - -NEVER_TIMESTAMP = int(-0x8000000000000000) +from samba.netcmd.common import (NEVER_TIMESTAMP, + timestamp_to_mins, + timestamp_to_days) def pso_container(samdb): return "CN=Password Settings Container,CN=System,%s" % samdb.domain_dn() -def timestamp_to_mins(timestamp_str): - """Converts a timestamp in -100 nanosecond units to minutes""" - # treat a timestamp of 'never' the same as zero (this should work OK for - # most settings, and it displays better than trying to convert - # -0x8000000000000000 to minutes) - if int(timestamp_str) == NEVER_TIMESTAMP: - return 0 - else: - return abs(int(timestamp_str)) / (1e7 * 60) - - -def timestamp_to_days(timestamp_str): - """Converts a timestamp in -100 nanosecond units to days""" - return timestamp_to_mins(timestamp_str) / (60 * 24) - - def mins_to_timestamp(mins): """Converts a value in minutes to -100 nanosecond units""" timestamp = -int((1e7) * 60 * mins) -- 2.47.3