]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool pso uses common timestamp functions
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 18 Nov 2020 22:20:35 +0000 (11:20 +1300)
committerNoel Power <npower@samba.org>
Wed, 9 Dec 2020 16:00:39 +0000 (16:00 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
python/samba/netcmd/pso.py

index 200b6ff2a9e812780d2056f1eebb9ebe967b2c1d..d260e3bd4064082cc65c9b95135a7135b653d748 100644 (file)
@@ -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)