Microsoft KB Archive/250611
Article ID: 250611
Article Last Modified on 11/1/2006
- Microsoft Windows NT Server 4.0 Standard Edition
This article was previously published under Q250611
The Date() function in the Rexx.exe scripting engine returns the year 100 instead of the year 00 when you use the E, O, or U switches.
The problem occurs because the localtime() C library function in the Rexx.exe source code returns the year as the number of years after 1900.
To resolve this issue, modify the source code and recompile the Rexx.exe script engine to handle year 2000 and later dates.
The Rexx.exe source code is included in the Microsoft Windows NT Resource Kit CD-ROM in the \Source\Gnu\Rexx folder.
For example, here is one way you can correct the source code:
The problems are in the std_date() function found in the source file builtin.c.
The code uses two characters for the year portion of the date, and stores it in the tmdata structure by the localtime() function. However, this is incorrect. For example:
case 'O': retval = Malloc(9+STRHEAD) ; sprintf(retval, fmt, tmdata->tm_year, tmdata->tm_mon+1, tmdata->tm_mday);
If you change the code above to the following code, the return is 00/01/10 for today's date:
case 'O': retval = Malloc(9+STRHEAD) ; sprintf(retval, fmt, tmdata->tm_year-100, tmdata->tm_mon+1, tmdata->tm_mday);
To potentially work around this problem:
Modify a Rexx script to accommodate this behavior. Here is a scripting example that does so.
say 'Modified output for date(o) function' x = date('o') y = translate(x,' ','/') year = word(y,1) month = word(y,2) day = word(y,3) x = year-100'/'month'/'day say x
- Use one of the Rexx date options that correctly return the date, such as 'S'.
- Omit the use of the year portion of the date in your script.
- Rewrite your scripts using Windows Scripting Host (WSH).
Microsoft has determine that this problem in the REXX.EXE source code is by design.
Keywords: kbenv kbprb KB250611