;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       fnInteger8Date()  
;; 
;;ACTION         Returns the Date/Time of an Integer8 date object in YYYY/MM/DD HH:MM:SS format. 
;; 
;;AUTHOR         Christopher Shilt 
;; 
;;CONTRIBUTORS   Richard Mueller, Jochen Polster, Bryce Lindsay 
;;               Code commented by Glenn Barnas 
;; 
;;VERSION        1.0 - 2005/08/17 
;; 
;;SYNTAX         fnInteger8Date(OBJDATE [, BIAS])  
;; 
;;PARAMETERS     OBJDATE - Required - Real 
;;               - Integer8 date object.  
;; 
;;               BIAS - Optional - Integer 
;;               - Timezone bias to adjust the time returned for the date object. If not 
;;               specified, it will use your default active timezone bias. If BIAS = 0, 
;;               then it will return the UTC date/time.  
;; 
;;REMARKS        Many attributes in Active Directory have a syntax called Integer8. 
;;               These 64-bit numbers (8 bytes) usually represent time in 100-nanosecond 
;;               intervals. If the Integer8 attribute is a date, the value represents the 
;;               number of 100-nanosecond  intervals since 12:00 AM January 1, 1601.  
;; 
;;               ADSI automatically employs the IADsLargeInteger interface to deal 
;;               with these 64-bit numbers. This interface has two property methods, 
;;               HighPart and LowPart, which break the number up into two 32-bit numbers. 
;;               The LowPart property method returns values between -2^31 and 2^31 - 1. 
;; 
;;RETURNS        A Interger8 Date Object in YYYY/MM/DD HH:MM:SS format.  
;; 
;;               Sets the value of @ERROR based on success/failure.  
;; 
;;DEPENDENCIES   none  
;; 
;;EXAMPLES       ; == Display the date/time the user last changed their password ==   
;;               $objSys = CreateObject("ADSystemInfo")  
;;               $objUser = GetObject("LDAP://"+$objSys.UserName)  
;; 
;;               "You last set your password on " + fnInteger8Date($objUser.pwdLastSet) + "." ?  
; 
Function fnInteger8Date($objDate, Optional $lngBias) 
 
  Dim $lngHigh, $lngLow						; high & low parts of date object 
  Dim $lngDate							; date as a Long 
  Dim $Pow							;  
  Dim $l							; counter 
  Dim $jdate							; Julian date 
  Dim $lngYear, $lngMonth, $lngDay				; year, month, day 
  Dim $s, $m, $h						; seconds, minutes, hours 
 
  If Not (VarType($objDate) & 9) Exit 87 EndIf			; exit if not a proper object reference 
 
  If VarType($lngBias) = 0
    $lngBias = Val(ReadValue('HKLM\System\CurrentControlSet\Control\TimeZoneInformation\', 'ActiveTimeBias'))
    If @ERROR Exit @ERROR EndIf
  EndIf
   
  $lngHigh = $objDate.HighPart 
  $lngLow = $objDate.LowPart 
 
  If $lngLow < 0 $lngHigh = $lngHigh + 1 EndIf
  If $lngHigh = 0 And $lngLow = 0 $lngBias = 0 EndIf
 
  $Pow = 2.0
 
  For $l = 1 to 31
    $Pow = 2.0 * $Pow
  Next
 
  $lngDate = ((CDBL($lngHigh) * $Pow + $lngLow) / 600000000 - $lngBias) / 1440 
 
  If $lngDate > 0
    $jdate = 584389 + Fix($lngDate)
 
    $lngYear  = (100*(((100*($jdate + 306) - 25) / 3652425) - (((100 * ($jdate + 306) - 25) / 3652425) / 4)) + (100 * ($jdate + 306) - 25)) / 36525 
    $lngMonth = (5*(((100*($jdate + 306) - 25) / 3652425) - (((100 * ($jdate + 306) - 25) / 3652425) / 4) + ($jdate + 306) - 365*$lngYear-$lngYear / 4) + 456) / 153 
    $lngDay   = (((100*($jdate + 306) - 25) / 3652425) - (((100 * ($jdate + 306) - 25) / 3652425) / 4) + ($jdate + 306) - 365 * $lngYear - $lngYear / 4) - (153 * $lngMonth - 457) / 5 
 
    If $lngMonth > 12
      $lngYear  = $lngYear + 1
      $lngMonth = $lngMonth - 12
    EndIf 
 
    $lngMonth = Right("0" + $lngMonth, 2) 
    $lngDay   = Right("0" + $lngDay, 2) 
 
    $s = Fix(86400.0 * ($lngDate - Fix($lngDate)))
    $m = $s / 60
    $s = $s mod 60
    $h = $m / 60
    $m = $m mod 60
 
    $fnInteger8Date = '' + $lngYear + '/' + $lngMonth + '/' + $lngDay + ' ' + $h + ':' + Right("0" + $m, 2) + ':' + Right("0" + $s, 2)
    Exit 0
 
  EndIf
 
  Exit 1
 
EndFunction