Old 2nd October 2004, 16:47   #1
edUT
Junior Member
 
Join Date: Oct 2004
Posts: 2
Talking new variables {__YEAR__} {__MONTH__} {__DAY__}

I made a custom version of MakeNsis.exe 201 to solve a reversioning problem.
I added 3 predefined variables.

PHP Code:
!define ${PRODUCT_VERSION"${__YEAR__}.${__MONTH__}.${__DAY__}
;-> 4.10.02 
In the script.cpp, 2 modified functions:
PHP Code:
void CEXEBuild::set_date_time_predefines()
{
  
time_t etime;
  
struct tm ltime;
  
char datebuf[128];
  
char timebuf[128];
  
char yearbuf[128];
  
char monthbuf[128];
  
char daybuf[128];

  
time(&etime);
  
ltime localtime(&etime);
#ifdef _WIN32
  
SYSTEMTIME stime;
  
stime.wYear ltime->tm_year+1900;
  
stime.wMonth ltime->tm_mon 1;
  
stime.wDay ltime->tm_mday;
  
stime.wHourltime->tm_hour;
  
stime.wMinuteltime->tm_min;
  
stime.wSecondltime->tm_sec;
  
stime.wMilliseconds0;
  
GetDateFormat(LOCALE_USER_DEFAULTDATE_SHORTDATE, &stimeNULLdatebufsizeof(datebuf));
  
definedlist.add("__DATE__",(char *)datebuf);
  
GetTimeFormat(LOCALE_USER_DEFAULT0, &stimeNULLtimebufsizeof(timebuf));
  
definedlist.add("__TIME__",(char *)timebuf);
  
GetDateFormat(LOCALE_USER_DEFAULT0, &stime"y"yearbufsizeof(yearbuf));
  
definedlist.add("__YEAR__",(char *)yearbuf);
  
GetDateFormat(LOCALE_USER_DEFAULT0, &stime"MM"monthbufsizeof(monthbuf));
  
definedlist.add("__MONTH__",(char *)monthbuf);
  
GetDateFormat(LOCALE_USER_DEFAULT0, &stime"dd"daybufsizeof(daybuf));
  
definedlist.add("__DAY__",(char *)daybuf);
#else
  
my_strftime(datebufsizeof(datebuf), "%x"ltime);
  
definedlist.add("__DATE__",(char *)datebuf);
  
my_strftime(timebufsizeof(timebuf), "%X"ltime);
  
definedlist.add("__TIME__",(char *)timebuf);
  
my_strftime(yearbufsizeof(yearbuf), "%y"ltime);
  
definedlist.add("__YEAR__",(char *)yearbuf);
  
my_strftime(monthbufsizeof(monthbuf), "%m"ltime);
  
definedlist.add("__MONTH__",(char *)monthbuf);
  
my_strftime(daybufsizeof(daybuf), "%d"ltime);
  
definedlist.add("__DAY__",(char *)daybuf);
#endif
}

void CEXEBuild::del_date_time_predefines()
{
  
definedlist.del("__DATE__");
  
definedlist.del("__TIME__");
  
definedlist.del("__YEAR__");
  
definedlist.del("__MONTH__");
  
definedlist.del("__DAY__");


Last edited by edUT; 2nd October 2004 at 17:24.
edUT is offline   Reply With Quote
Old 2nd October 2004, 21:28   #2
edUT
Junior Member
 
Join Date: Oct 2004
Posts: 2
i would cool if you can include this in the next release
edUT is offline   Reply With Quote
Old 3rd October 2004, 01:42   #3
bluenet
Senior Member
 
Join Date: Mar 2004
Posts: 138
Some times we like "${__YEAR__}.${__MONTH__}.${__DAY__}" but not "${__YEAR__}-${__MONTH__}-${__DAY__}" it's usefull. Hope include in the next release.
bluenet is offline   Reply With Quote
Old 10th October 2004, 13:39   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I think it would be best to make a define switch, or a new command that allows the user to select his own format. That'd also allow to get different times in different places in the script.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump