NSIS-Date plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
(Macro added (Veekee))
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|Afrow UK}}
|<small>Author: [[{{ns:2}}:Afrow UK|Afrow UK]] ([[{{ns:3}}:Afrow UK|talk]], [[{{ns:-1}}:Contributions/Afrow UK|contrib]])</small>
 
|}
<br style="clear:both;">
== Recommendation ==
== Recommendation ==
Getting the local time is also possible using Windows API. Using this alternative method is recommended, because NSIS-Date seems to have some problems with timezones/summertime. See [[Get Current Time]].
Getting the local time is also possible using Windows API. Using this alternative method is recommended, because NSIS-Date seems to have some problems with timezones/summertime. See [[GetTime]].


== Links ==
== Links ==
<attach>nsisdt.zip</attach>
<attach>Nsisdt.zip</attach>


== Description ==
== Description ==
This plugin allows you to insert the date and / or time anywhere into your installer.
This plugin allows you to insert the date and / or time anywhere into your installer.
== Plugin Readme ==
 
<pre>NSIS-Date 1.0
== Plugin's Readme ==
 
<pre>
NSIS-Date 1.0
Copyright (C) 2001 Robert Rainwater <rrainwater@yahoo.com>
Copyright (C) 2001 Robert Rainwater <rrainwater@yahoo.com>
This software is provided 'as-is', without any express or implied
This software is provided 'as-is', without any express or implied
Line 27: Line 29:
misrepresented as being the original software.
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
Usage Information -----------------
Usage Information
Step 1: Generate a format string using the following:     %a    abbreviated weekday name (Sun)     %A    full weekday name (Sunday)     %b    abbreviated month name (Dec)     %B    full month name (December)     %c    date and time (Dec  2 06:55:15 1979)     %d    day of the month (02)     %H    hour of the 24-hour day (06)     %I    hour of the 12-hour day (06)     %j    day of the year, from 001 (335)     %m    month of the year, from 01 (12)     %M    minutes after the hour (55)     %p    AM/PM indicator (AM)     %S    seconds after the minute (15)     %U    Sunday week of the year, from 00 (48)     %w    day of the week, from 0 for Sunday (6)     %W    Monday week of the year, from 00 (47)     %x    date (Dec  2 1979)     %X    time (06:55:15)
-----------------
    %y    year of the century, from 00 (79)     %Y    year (1979)     %Z    time zone name, if any (EST)     %%    percent character %
Step 1:
Step 2: Call currentdate
Generate a format string using the following:
Step 3: The current date is returned into $0.
    %a    abbreviated weekday name (Sun)
    %A    full weekday name (Sunday)
    %b    abbreviated month name (Dec)
    %B    full month name (December)
    %c    date and time (Dec  2 06:55:15 1979)
    %d    day of the month (02)
    %H    hour of the 24-hour day (06)
    %I    hour of the 12-hour day (06)
    %j    day of the year, from 001 (335)
    %m    month of the year, from 01 (12)
    %M    minutes after the hour (55)
    %p    AM/PM indicator (AM)
    %S    seconds after the minute (15)
    %U    Sunday week of the year, from 00 (48)
    %w    day of the week, from 0 for Sunday (6)
    %W    Monday week of the year, from 00 (47)
    %x    date (Dec  2 1979)
    %X    time (06:55:15)
    %y    year of the century, from 00 (79)
    %Y    year (1979)
    %Z    time zone name, if any (EST)
    %%    percent character %
Step 2:
Call currentdate
Step 3:
The current date is returned into $0.


Example:</pre>
Example:</pre>
<highlight-nsis> File /oname=$TEMP
 
sisdt.dll nsisdt.dll
<highlight-nsis>
File /oname=$TEMP\nsisdt.dll nsisdt.dll
StrCpy $0 "%Y.%m.%d-%H.%M"
CallInstDLL "$TEMP\nsisdt.dll" currentdate
MessageBox MB_OK "Date=$0"</highlight-nsis>
New syntax:
<highlight-nsis>
StrCpy $0 "%Y.%m.%d-%H.%M"
StrCpy $0 "%Y.%m.%d-%H.%M"
CallInstDLL "$TEMP
nsisdt::currentdate
sisdt.dll" currentdate
MessageBox MB_OK "Date=$0"
MessageBox MB_OK "Date=$0" </highlight-nsis>
</highlight-nsis>
Macro:
<highlight-nsis>
!macro GETDATE OUTPUT FORMAT
Push $0
StrCpy $0 "${FORMAT}"
nsisdt::currentdate
StrCpy ${OUTPUT} "$0"
Pop $0
!macroend
</highlight-nsis>
Thanks [[user:Rainwater|Rainwater]]!
Thanks [[user:Rainwater|Rainwater]]!


[[{{ns:14}}:Plugins]]
[[Category:Plugins]]

Latest revision as of 10:06, 12 January 2009

Author: Afrow UK (talk, contrib)


Recommendation

Getting the local time is also possible using Windows API. Using this alternative method is recommended, because NSIS-Date seems to have some problems with timezones/summertime. See GetTime.

Links

Nsisdt.zip (4 KB)

Description

This plugin allows you to insert the date and / or time anywhere into your installer.

Plugin's Readme

NSIS-Date 1.0
Copyright (C) 2001 Robert Rainwater <rrainwater@yahoo.com>
This software is provided 'as-is', without any express or implied
warranty.  In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Usage Information
-----------------
Step 1:
	Generate a format string using the following:
	    %a    abbreviated weekday name (Sun)
	    %A    full weekday name (Sunday)
	    %b    abbreviated month name (Dec)
	    %B    full month name (December)
	    %c    date and time (Dec  2 06:55:15 1979)
	    %d    day of the month (02)
	    %H    hour of the 24-hour day (06)
	    %I    hour of the 12-hour day (06)
	    %j    day of the year, from 001 (335)
	    %m    month of the year, from 01 (12)
	    %M    minutes after the hour (55)
	    %p    AM/PM indicator (AM)
	    %S    seconds after the minute (15)
	    %U    Sunday week of the year, from 00 (48)
	    %w    day of the week, from 0 for Sunday (6)
	    %W    Monday week of the year, from 00 (47)
	    %x    date (Dec  2 1979)
	    %X    time (06:55:15)
	    %y    year of the century, from 00 (79)
	    %Y    year (1979)
	    %Z    time zone name, if any (EST)
	    %%    percent character %
Step 2:
	Call currentdate
Step 3:
	The current date is returned into $0.

Example:
File /oname=$TEMP\nsisdt.dll nsisdt.dll
StrCpy $0 "%Y.%m.%d-%H.%M"
CallInstDLL "$TEMP\nsisdt.dll" currentdate
MessageBox MB_OK "Date=$0"

New syntax:

StrCpy $0 "%Y.%m.%d-%H.%M"
nsisdt::currentdate 
MessageBox MB_OK "Date=$0"

Macro:

!macro GETDATE OUTPUT FORMAT
	Push $0
	StrCpy $0 "${FORMAT}"
	nsisdt::currentdate
	StrCpy ${OUTPUT} "$0"
	Pop $0
!macroend

Thanks Rainwater!