From 12df15a9e59e6835ea39d90c20f2d3954deb6746 Mon Sep 17 00:00:00 2001 From: kichik Date: Tue, 28 Mar 2006 18:20:28 +0000 Subject: [PATCH] implemented RFE #1459210 - !define /date should use UTC added /utcdate flag git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4622 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/defines.but | 4 ++-- Source/script.cpp | 7 ++++++- Source/tokens.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Docs/src/defines.but b/Docs/src/defines.but index b16d989d..2351d0e0 100644 --- a/Docs/src/defines.but +++ b/Docs/src/defines.but @@ -10,11 +10,11 @@ Define/conditional compilation related commands: \S1{define} !define -\c ([/date] gflag [value]) | (/math gflag val1 OP val2) +\c ([/date|/utcdate] gflag [value]) | (/math gflag val1 OP val2) This command will add \e{gflag} to the global define list. This will have a similar effect as using the /D switch on the command line (only the define only becomes effective after the !define command). -If \e{/date} is used, \e{value} will be passed into strftime and the result will be used as the value of \e{gflag}. strftime converts special symbols into certain parts of the current time or date. For example, %H will be converted into the current hour in 24-hour format. For a complete list of available symbols, search for strftime on \W{http://msdn.microsoft.com/}{MSDN}. On POSIX, you can get the list by using \c{man strftime}. +If \e{/date} or \e{/utcdate} are used, \e{value} will be passed into strftime and the result will be used as the value of \e{gflag}. strftime converts special symbols into certain parts of the current time or date. For example, %H will be converted into the current hour in 24-hour format. For a complete list of available symbols, search for strftime on \W{http://msdn.microsoft.com/}{MSDN}. On POSIX, you can get the list by using \c{man strftime}. If \e{/math} is used, the result of 'val1 OP val2', where OP may be +,-,*,/ or % , will be used as the value of \e{gflag}. Note that val1 AND val2 MUST be integer values! diff --git a/Source/script.cpp b/Source/script.cpp index 736378f1..b89d2f87 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -2693,15 +2693,20 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) char mathbuf[256]; bool date=false; - if (!stricmp(define,"/date")) { + if (!stricmp(define,"/date") || !stricmp(define,"/utcdate")) { if (line.getnumtokens()!=4) PRINTHELP() + char *date_type = define; + define=line.gettoken_str(2); value=line.gettoken_str(3); time_t rawtime; time(&rawtime); + if (!stricmp(date_type,"/utcdate")) + rawtime = mktime(gmtime(&rawtime)); + datebuf[0]=0; size_t s=strftime(datebuf,sizeof(datebuf),value,localtime(&rawtime)); diff --git a/Source/tokens.cpp b/Source/tokens.cpp index 7bdae21e..644efceb 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -229,7 +229,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_P_IFDEF,"!ifdef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL}, {TOK_P_IFNDEF,"!ifndef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]",TP_ALL}, {TOK_P_ENDIF,"!endif",0,0,"",TP_ALL}, -{TOK_P_DEFINE,"!define",1,4,"([/date] symbol [value]) | (/math symbol val1 OP val2)\n OP=(+ - * / %)",TP_ALL}, +{TOK_P_DEFINE,"!define",1,4,"([/date|/utcdate] symbol [value]) | (/math symbol val1 OP val2)\n OP=(+ - * / %)",TP_ALL}, {TOK_P_UNDEF,"!undef",1,1,"symbol [value]",TP_ALL}, {TOK_P_ELSE,"!else",0,-1,"[if[macro][n][def] ...]",TP_ALL}, {TOK_P_ECHO,"!echo",1,0,"message",TP_ALL},