From: Douglas Bagnall Date: Wed, 18 Nov 2020 22:20:35 +0000 (+1300) Subject: samba-tool pso uses common timestamp functions X-Git-Tag: samba-4.14.0rc1~483 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c48e90fad04db6a78fc4dc1f2cb12154db7f711;p=thirdparty%2Fsamba.git samba-tool pso uses common timestamp functions Signed-off-by: Douglas Bagnall Reviewed-by: Noel Power --- 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)