Get Local Time: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Fixed small spelling errors.) |
mNo edit summary |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|deguix}} | |||
== Description == | == Description == | ||
'''Superseded by:''' [[GetTime]] function.<br> | '''Superseded by:''' [[GetTime]] function.<br> | ||
'''Requires:''' [[System]] plugin. | '''Requires:''' [[System plug-in|System]] plugin. | ||
This function gets the current local time of the user's computer. | This function gets the current local time of the user's computer. | ||
== Function Call == | == Function Call == | ||
<highlight-nsis> | |||
Call GetLocalTime | |||
Pop "$var1" ;Variable (for day) | |||
Pop "$var2" ;Variable (for month) | |||
Pop "$var3" ;Variable (for year) | |||
Pop "$var4" ;Variable (for day of week name) | |||
Pop "$var5" ;Variable (for hour) | |||
Pop "$var6" ;Variable (for minute) | |||
Pop "$var7" ;Variable (for second) | |||
</highlight-nsis> | |||
== Function Code == | == Function Code == | ||
<highlight-nsis> | |||
<highlight-nsis>;---------------------------------------------------------------------------- | ;---------------------------------------------------------------------------- | ||
; Superseded by : GetTime function. | ; Superseded by : GetTime function. | ||
;---------------------------------------------------------------------------- | ;---------------------------------------------------------------------------- | ||
Line 34: | Line 36: | ||
; | ; | ||
; Pop "$Variable1" | ; Pop "$Variable1" | ||
; | ; Day. | ||
; | ; | ||
; Pop "$Variable2" | ; Pop "$Variable2" | ||
Line 40: | Line 42: | ||
; | ; | ||
; Pop "$Variable3" | ; Pop "$Variable3" | ||
; | ; Year. | ||
; | ; | ||
; Pop "$Variable4" | ; Pop "$Variable4" | ||
Line 127: | Line 129: | ||
Exch 6 | Exch 6 | ||
FunctionEnd</highlight-nsis> | FunctionEnd | ||
</highlight-nsis> | |||
[[Category:Date & Time Functions]] |
Latest revision as of 05:33, 12 November 2005
Author: deguix (talk, contrib) |
Description
Superseded by: GetTime function.
Requires: System plugin.
This function gets the current local time of the user's computer.
Function Call
Call GetLocalTime Pop "$var1" ;Variable (for day) Pop "$var2" ;Variable (for month) Pop "$var3" ;Variable (for year) Pop "$var4" ;Variable (for day of week name) Pop "$var5" ;Variable (for hour) Pop "$var6" ;Variable (for minute) Pop "$var7" ;Variable (for second)
Function Code
;---------------------------------------------------------------------------- ; Superseded by : GetTime function. ;---------------------------------------------------------------------------- ; Title : Get Local Time ; Short Name : GetLocalTime ; Last Changed : 22/Feb/2005 ; Code Type : Function ; Code Sub-Type : One-way Output ;---------------------------------------------------------------------------- ; Required : System plugin. ; Description : Gets the current local time of the user's computer ;---------------------------------------------------------------------------- ; Function Call : Call GetLocalTime ; ; Pop "$Variable1" ; Day. ; ; Pop "$Variable2" ; Month. ; ; Pop "$Variable3" ; Year. ; ; Pop "$Variable4" ; Day of the week name. ; ; Pop "$Variable5" ; Hour. ; ; Pop "$Variable6" ; Minute. ; ; Pop "$Variable7" ; Second. ;---------------------------------------------------------------------------- ; Author : Diego Pedroso ; Author Reg. Name : deguix ;---------------------------------------------------------------------------- Function GetLocalTime # Prepare variables Push $0 Push $1 Push $2 Push $3 Push $4 Push $5 Push $6 # Call GetLocalTime API from Kernel32.dll System::Call '*(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) i .r0' System::Call 'kernel32::GetLocalTime(i) i(r0)' System::Call '*$0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)i \ (.r4, .r5, .r3, .r6, .r2, .r1, .r0,)' # Day of week: convert to name StrCmp $3 0 0 +3 StrCpy $3 Sunday Goto WeekNameEnd StrCmp $3 1 0 +3 StrCpy $3 Monday Goto WeekNameEnd StrCmp $3 2 0 +3 StrCpy $3 Tuesday Goto WeekNameEnd StrCmp $3 3 0 +3 StrCpy $3 Wednesday Goto WeekNameEnd StrCmp $3 4 0 +3 StrCpy $3 Thursday Goto WeekNameEnd StrCmp $3 5 0 +3 StrCpy $3 Friday Goto WeekNameEnd StrCmp $3 6 0 +2 StrCpy $3 Saturday WeekNameEnd: # Minute: convert to 2 digits format IntCmp $1 9 0 0 +2 StrCpy $1 '0$1' # Second: convert to 2 digits format IntCmp $0 9 0 0 +2 StrCpy $0 '0$0' # Return to user Exch $6 Exch Exch $5 Exch Exch 2 Exch $4 Exch 2 Exch 3 Exch $3 Exch 3 Exch 4 Exch $2 Exch 4 Exch 5 Exch $1 Exch 5 Exch 6 Exch $0 Exch 6 FunctionEnd