[python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon?

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Nov 10 09:49:14 CET 2004


[R. Alan Monroe]

| > I'm looking at the
| > "PasswordLastChanged" property,
| 
| Looking at the .tlb I can see that PasswordLastChanged returns:
| [id(0x0000003b), propget]
| HRESULT PasswordLastChanged([out, retval] DATE* retval);
| 
| If I do type() on the variable I assign it to, it says 'time', and it
| prints a sensible looking date like 10/25/04 11:18:59 to the screen.
| But I can't figure out how to compare that to, say, time.time(). How
| do I find out the number of elapsed days between the date it returns
| and the current date?

The pywin32 docs for PyTime state that calling int () on a
PyTime object will convert it to the result as if you'd used
time.time (). So something like the following makes sense:

<code>

import time

[...]

now = time.time ()
password_last_changed = int (me.PasswordLastChanged)

print "Password changed on", time.asctime (time.localtime
(password_last_changed))
print "Password changed", now - password_last_changed, "seconds ago"

</code>

Obviously you can do what you like once you've got the 
time.time ()-like value.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the Python-win32 mailing list