Archive: Working Installation CompletionTime function (uses NSISdt)


Working Installation CompletionTime function (uses NSISdt)
This is a new script to show the start and finish (completion) time for the installation process.
I was wondering if somone could help test it for me, just to be sure that there's nothing naff!

http://nsis.sourceforge.net/archive/...11&instances=0

Also, could the old "Report Installation Time at End" script on the Archive be removed, or blocked out, because that one does not work correctly (sometimes outputs minus values!)

Thanks

-Stu


Is better use System.dll, because have an old bug in it (it adds +1 hour when is winter here - Brazil).

[EDIT]It works, but is not better to give user the chance to customize the result string, using more pops to pop the hour, minute and second?[/EDIT]


Originally posted by deguix
Is better use System.dll, because have an old bug in it (it adds +1 hour when is winter here - Brazil).

[EDIT]It works, but is not better to give user the chance to customize the result string, using more pops to pop the hour, minute and second? [/EDIT]
Yes that's a good idea! Will get onto that now.
About the 1 hour thing...
I was getting that too!
Is that my script or NSISdt?

Edit:
Added extra "output mode"
So, how would I get the 3 times (hours,mins,secs) using System, just like I have done with NSISdt (if that fixes the hour problem?)

-Stu

NSISdt! Use this code to get all you need to use with System Plugin:

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .r1'
System::Call 'kernel32::GetLocalTime(i) i(r1)'
System::Call '*$1(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(.r6, .r5, .r4,, .r3, .r2, .r1,)'

;$1 = seconds
;$2 = minutes
;$3 = hours
;$4 = day
;$5 = month
;$6 = year

(Based on "Get Local Time" function, see my signature)


Thanks!
Is there a way to chop it down to just 3 variables (hours,mins,secs)


More one: the function have to calculate the days, months and years too, i.e. when I start the installation at 11:59 PM and end at 12:00 AM, will show negative numbers. So you have to remove the week day and miliseconds. I edited my previous post to it.


This will make things a lot harder.
I think I know how to fix it though...


Try now: http://nsis.sourceforge.net/archive/...instances=0,11
Notice the new Push.

I've added a few lines in to notice the change in hours/mins/secs etc.
I cannot test it right now (on a PC without NSIS)

I have a feeling there's something else that needs changing...

Also, I'm stall using NSISdt until I can use System to get just hours (in 24 hour format), mins and seconds.

-Stu


To remove temporary the days, months and years remove .r4, .r5 and .r6 to don't use the variables $4, $5 and $6 (and preserve commas)! The hours using the code above are in 24h format too.

[EDIT]Have something wrong now with your function, are giving "24 hours, 60 mins, 60 secs". And is better to use the first version, not use anymore that additional push, because I forgot that can use "StrCpy" to customize the strings...[/EDIT]


Ok.
I will attempt to repair the function any minute now (when the other pc is free!)
Is it possible to get the day of the year usung System too?

-Stu


Ok.
System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .r1'
System::Call 'kernel32::GetLocalTime(i) i(r1)'
System::Call '*$1(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) (, .r1, .r2, .r3,,,,,)'
detailprint ">>$3:$2:$1"
Output is: ">>28:6:6"

What's wrong?

-Stu


Not. Have only to use milisecond, second, minute, hour, day, day of week (in number), month, year. But can make a function for it!


I don't understand :(


I said no, and the only things that you can use with GetLocalTime API are: milisecond, second, minute, hour, day, day of week (in number), month and year. But you can make a function that does it.


Originally posted by deguix
I said no, and the only things that you can use with GetLocalTime are: milisecond, second, minute, hour, day, day of week (in number), month, year. But you can make a function that does it.
Oh, I see!
So, whats up with the strange output I am getting?

With System I get 6 seconds, 6 minutes, and 28 hours for the current time!

-Stu

Wow, I'm blind, I do not saw that post. This is the right one code:

System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .r1'
System::Call 'kernel32::GetLocalTime(i) i(r1)'
System::Call '*$1(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)(,,,, .r3, .r2, .r1,)'

(I only inverted the position)

[EDIT]I fixed the code above, now is the RIGHT one! Tested and retested...:up:[/EDIT]


Works great now!
I ended up removing the option to only display seconds or minutes and seconds.
The reason is because;
if the installation took 1 min, 1 sec, then the completion time would be "1 sec."!

I could repair this, but it starts to get messy...

-Stu


mmm...
I read this thread quickly, but doesn't this do the completion time?


Ok, I will check this out a bit more.
When I tested, I was getting negative results.

Now, however, it seems to be working...

-Stu


I'll remove mine, because your's is better!
Would you like me to transfer your's to my function, with added functionality like "Output Options" where it simply displays Hours, Mins, or Seconds (3|2|1).

I will write the value ($R9) to the temp file and read it at the end so that $R9 does not get messed around with during the installation (like had happened to me)

-Stu


This new function is good - it only uses 3 variables!
Here's what I ended up with...

Usage 1:
# place this at the start of the first section
Push start ;signifies to start counting.
Push 0 ;output mode (for finish only)
Call CompletionTime
Pop $0 ;output (0 at start)

Usage 2:
# place this at the end of the last section
Push finish ;signifies to finish & output completion time
Push 1 ;output mode (1=secs|2=mins|3=hours)
Call CompletionTime
Pop $0 ;output (depends on output mode)

The Function:

Function CompletionTime
# // Original script by n0On3.
# \\ Added Output Options, and Function style by Afrow UK.
Exch $R0 ;output mode
Exch
Exch $R1 ;start|finish
Push $R2

WriteINIStr "$TEMP\completion_time.tmp" "Mode" "Value" "$R0"

StrCpy $R2 0

StrCmp $R1 start 0 finish
SetDetailsPrint "none"
GetTempFileName $R0
GetFileTime $R0 $R1 $R2
Delete $R0

WriteINIStr "$TEMP\completion_time.tmp" "Time" "Value" "$R2"

SetDetailsPrint "both"
Goto exit

finish:
SetDetailsPrint "none"
GetTempFileName $R0
GetFileTime $R0 $R1 $R2
Delete $R0

ReadINIStr $R0 "$TEMP\completion_time.tmp" "Time" "Value"

IntOp $R2 $R2 - $R0
IntOp $R2 $R2 / 10000000

ReadINIStr $R0 "$TEMP\completion_time.tmp" "Mode" "Value"

StrCmp $R0 1 +6 ;time in secs
StrCmp $R0 2 0 +3
IntOp $R2 $R2 / 60 ;time in mins
Goto +3
StrCmp $R0 3 0 +2
IntOp $R2 $R2 / 60 ;time in mins

Delete "$TEMP\completion_time.tmp"
SetDetailsPrint "both"

exit:
StrCpy $R0 $R2

Pop $R2
Pop $R1
Exch $R0
FunctionEnd

Just found a small problem, fixed it.
Would you put this with your script or shall I put it over mine (on archive)?
The Function:

Function CompletionTime
# // Original script by n0On3.
# \\ Added Output Options, and Function style by Afrow UK.
Exch $R0 ;output mode
Exch
Exch $R1 ;start|finish
Push $R2

WriteINIStr "$TEMP\completion_time.tmp" "Mode" "Value" "$R0"

StrCpy $R2 0

StrCmp $R1 start 0 finish
SetDetailsPrint "none"
GetTempFileName $R0
GetFileTime $R0 $R1 $R2
Delete $R0

WriteINIStr "$TEMP\completion_time.tmp" "Time" "Value" "$R2"

SetDetailsPrint "both"
Goto exit

finish:
SetDetailsPrint "none"
GetTempFileName $R0
GetFileTime $R0 $R1 $R2
Delete $R0

ReadINIStr $R0 "$TEMP\completion_time.tmp" "Time" "Value"

IntOp $R2 $R2 - $R0
IntOp $R2 $R2 / 10000000

ReadINIStr $R0 "$TEMP\completion_time.tmp" "Mode" "Value"

StrCmp $R0 1 +6 ;time in secs
StrCmp $R0 2 0 +3
IntOp $R2 $R2 / 60 ;time in mins
Goto +4
StrCmp $R0 3 0 +3
IntOp $R2 $R2 / 60 ;time in mins
IntOp $R2 $R2 / 60 ;time in hours

Delete "$TEMP\completion_time.tmp"
SetDetailsPrint "both"

exit:
StrCpy $R0 $R2

Pop $R2
Pop $R1
Exch $R0
FunctionEnd

Ok, the "Report Installation Time At The End" script only works on installation processes that take less than 60 seconds.
My process (map compile) took around 3345 seconds, and the script (above) reported the installation time as -87 seconds!

I will keep my script, and add extra functionality for use in long processes.

-Stu


I think the final release is out now...
I re-wrote the script, to make it tidier (and it is too!)

The Output Options is back too, and works perfectly.
The script still only works up to 24 hours (or before the next day)

-Stu


mmmm... I'll try to make it work for more than 60 seconds...


Originally posted by n0On3
mmmm... I'll try to make it work for more than 60 seconds...
I think it's 60 seconds...
Just put Sleep 61000 to see what happens.

-Stu