GetFileTime ISO 8601: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
No edit summary
Line 4: Line 4:
Simple implementation to get the [http://en.wikipedia.org/wiki/ISO_8601 ISO_8601] formatted modified time of a file.
Simple implementation to get the [http://en.wikipedia.org/wiki/ISO_8601 ISO_8601] formatted modified time of a file.


== Usage ==[[Media:Example.ogg]]
== Usage ==
<highlight-nsis>
<highlight-nsis>
     ${GetFileTime_ISO_8601} $0 "Test.exe"
     ${GetFileTime_ISO_8601} $0 "Test.exe"

Revision as of 19:29, 3 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