Archive: If it's this date, do this...


If it's this date, do this...
Hi!

I need my installer to check what date it is, and make it one string, like: $DATE, would print: 20050505

Thing is, I need my installer to do different thing depending on what date it is.

Any idea?


Thanks a lot!


http://nsis.sourceforge.net/archive/...php?pageid=156


There is also another date/time function available at
http://nsis.sourceforge.net/archive/...php?pageid=257 (You may need to slightly modify the result of either function so that you get your $DATE value returned in YYYYMMDD format.)

And if you set $DATE in .onInit, then you'll be able to use it wherever you need in the main script.


Hmmm... maybe I should develop more on Get Local Time, but you can tweak with the variables to get that result:


# Call GetLocalTime function
Call GetLocalTime
Pop $0
Pop $1
Pop $2
Pop $3
Pop $4
Pop $5
Pop $6

# Month: convert to 2 digits format
IntCmp $1 10 +2 0 +2
StrCpy $0 '0$0'
# Day: convert to 2 digits format
IntCmp $2 10 +2 0 +2
StrCpy $0 '0$0'

# Final date format "yyyyMMdd"
StrCpy $DATE "$0$1$2"

Thanks a lot you both,

just one question;

How do I make the date one single varible - how can I push together a few variables to one so that I get the date in $DATE?


Thanks!


Oh thanks, you posted the solution just as I was typing.

I'll try that! =)

Thanks!


I'm terrebly sorry for asking, but I've been searching a long time now..

Where do I find the plugin-dll which will enable this function??

I just can't ind it.. or am I blind..

Thanks!


The actual GetLocalTime function can be found at deguix's link from the previous post.

The function itself uses the system plugin (system.dll), which is included with the NSIS installation. (should be in your plugins folder.)


oh I see.. :)

Thanks mate!


Hi again!

I really feel stupid for asking again, but it just wont work..

Now, I have installed the scripts in nsh.zip, but wehre do I put the function code for GetLocalTime?

I assume that I should save the code as an .nsh and put it somewhere in my NSIS directory, but where?


Thanks a lot for all your help!!!!!


miakki,

Copy the code of GetLocalTime and paste it into a function in your main nsis script.

Function GetLocalTime

(... code of the function ...)

FunctionEnd


miakki, GetLocalTime isn't included in "nsh.zip". There is other function GetTime. If you want to use GetLocalTime see what wrote DavidV. If you want use GetTime for get local time:

Name "Output"
OutFile "Output.exe"

!include "FileFunc.nsh"
!insertmacro GetTime

Section
${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
; $0="13" day
; $1="12" month
; $2="2004" year
; $3="Monday" day of week name
; $4="16" hour
; $5="05" minute
; $6="50" seconds

MessageBox MB_OK 'Date=$0/$1/$2 ($3)$\nTime=$4:$5:$6'
SectionEnd


BTW: NSIS-Date 1.0 plugin has many different time features.

Watch with that code deguix!:

# Month: convert to 2 digits format
IntCmp $1 10 +2 0 +2
StrCpy $1 '0$1'
# Day: convert to 2 digits format
IntCmp $2 10 +2 0 +2
StrCpy $2 '0$2'

-Stu