GetFileTime ISO 8601: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
m (→‎The Function: Corrected Bug in Code)
Line 31: Line 31:
     System::Call "Kernel32::GetTimeFormatA(i 0, i 0, i r1, t 'THH:mm:ssZ', t .r1, i ${NSIS_MAX_STRLEN})"
     System::Call "Kernel32::GetTimeFormatA(i 0, i 0, i r1, t 'THH:mm:ssZ', t .r1, i ${NSIS_MAX_STRLEN})"


     StrCpy $0 $0.$1
     StrCpy $0 $0$1
      
      
     Pop $1
     Pop $1

Revision as of 19:00, 10 November 2009

Author: Zinthose (talk, contrib)


Description

Simple implementation to get the ISO_8601 formatted modified time of a file.

Usage

    ${GetFileTime_ISO_8601} $0 "Test.exe"
    DetailPrint "TimeStamp = $0"
    ; OutPut: TimeStamp = 2009-11-03.T19:14:58Z

The Function

!define GetFileTime_ISO_8601 "!insertmacro _GetFileTime_ISO_8601"
!macro _GetFileTime_ISO_8601 _VAR _FilePath
    ClearErrors
 
    Push $0
    Push $1
 
    GetFileTime "${_FilePath}" $1 $0
    System::Int64Op $1 * 0x100000000
    Pop $1
    System::Int64Op $1 + $0
    Pop $0
 
    System::Call "*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .r1"
    System::Call "Kernel32::FileTimeToSystemTime(*l r0, i r1)"
    System::Call "Kernel32::GetDateFormatA(i 0, i 0, i r1, t 'yyyy-MM-dd', t .r0, i ${NSIS_MAX_STRLEN})"
    System::Call "Kernel32::GetTimeFormatA(i 0, i 0, i r1, t 'THH:mm:ssZ', t .r1, i ${NSIS_MAX_STRLEN})"
 
    StrCpy $0 $0$1
 
    Pop $1
    Exch $0
 
    Pop ${_VAR}
!macroend