---------------------------------------------------------------- SETDATE v1.01 - Documentation Written 16 January 2000 by Robert B. Clark ClarkWehyr Enterprises This program is PUBLIC DOMAIN. ---------------------------------------------------------------- What is SETDATE? ~~~~~~~~~~~~~~~~ SETDATE is a small DOS utility that allows you to set the system date to any arbitrary date, or to any arbitrary offset of the current date. Now that we're in the midst of Y2K, people have found that some older software will simply not work if the system date is past 31 December 1999. By using SETDATE in a simple batch file, you can continue to use this legacy software relatively painlessly. SETDATE was written in C using Borland Turbo C++ v3.0. The source code does not purport to be portable, but it should be easy to modify it to compile under major C compilers for DOS. The code compiles as-is under the following compilers: * Borland Turbo C++ v3.0 * Borland Turbo C++ v5.0 (presumably also v4.x) * DJGPP GNU C v2.95.1 System Requirements ~~~~~~~~~~~~~~~~~~~ SETDATE is a DOS utility and its requirements are quite modest: * An IBM-PC AT or equivalent. * DOS version 3.0 or better (runs fine under Windows 95/98). * Roughly 60 kb free conventional RAM. Installing SETDATE ~~~~~~~~~~~~~~~~~~ Simply extract the SETDT101.ZIP archive into any directory in your PATH to which you have read and write privileges. That's all. Using SETDATE ~~~~~~~~~~~~~ You can view the usage summary by typing SETDATE /? at the command line: -=-=-=-=- Sets system date to a specified date or to an offset of the current date. SETDATE [ date | [+|-]offset[d|w|m|y]] | [RECALL] date Date to set, specified as MM-DD-YYYY or MM-DD-YY. Years 0-79 are 2000-2079; 80-99 are assumed to be 1980-1999. offset Number of days from now, expressed as ñ days (default), weeks (7 days), months (30 days) or years (365 days). RECALL Recalls a previously saved date. Only one saved date is in effect at any one time; recalling it clears the saved date. If neither 'date' nor 'offset' are given, 'date' defaults to 01-01-1980. Examples: SETDATE -15m Sets the date back 15 months (450 days). SETDATE 45 Sets the date to 45 days from now. SETDATE 1.2.3 Sets the date to 2 January 2003. SETDATE recall Recalls the previously saved date. SETDATE v1.01 21 January 2000 by Robert B. Clark Donated to the PUBLIC DOMAIN by the author. -=-=-=-=- In more detail, the command line arguments are explained below. Note that all arguments are case-insensitive. date SETDATE uses the current code page information to determine the country-specific date and time display format (see the DOS utility NLSFUNC for more information). The date examples shown in the online help are in the format detected at runtime. If your country uses DD-MM-YY, all dates will be presented to you in that format. Date separators may be any of [.-/] regardless of the code page setting. offset Instead of specifying an explicit date, you can tell SETDATE to set the date to a certain number of days from now (positive number) or to a certain number of days ago (negative number). You can append d, w, m or y (case-insensitive) to this offset to indicate days, weeks, months or years. You may use either a date or an offset, but not both. RECALL When first run, SETDATE saves the current date to a data file. Subsequent invocations of SETDATE without the RECALL parameter do not overwrite this file. When RECALL is specified, SETDATE resets the system date from the data file and the file is then deleted. RECALL may be abbreviated as R. By default, this data file is saved in the SETDATE.EXE home directory. You may specify another directory to store the data file; to do this set a DOS environment variable named SETDATE_DATA before invoking SETDATE.EXE: rem Save data files in C:\TEMP set setdate_data=C:\TEMP rem Set date to 1-1-80 (default) setdate rem Your stuff here rem Restore date setdate recall If SETDATE.EXE is in a directory to which you do NOT have write access, you MUST use the SETDATE_DATA variable to indicate where the data file may be stored. Usage Examples ~~~~~~~~~~~~~~ We'll close by presenting a few concrete examples: 1) Your comic book collection software does not work properly with a system date set beyond 31 December 1999. Other than that, it's a decent program and you want to keep using it. This is a DOS program that is invoked as C:\CBC\CBC.EXE. Use the following batch file: @echo off rem Runs CBC with a system date of 1 December 1999 c: cd \cbc setdate 12/1/99 cbc setdate recall 2) Each day when you boot your system, you need to set the system date back one year for legacy software maintenance. Append the following to your AUTOEXEC.BAT file: rem Legacy software maintenance setdate -1y if errorlevel 1 goto Error rem Do your stuff here setdate r :Error 3) Your system administrator has placed SETDATE.EXE in a read-only directory on the server. You are using the German code page on your PC, therefore your date format is DD.MM.YY or DD.MM.YYYY. rem Direct SETDATE.DAT file to local disk set setdate_data=c:\work rem Must set date to 23 June 1987 setdate 23.6.87 rem Do your stuff here setdate r Errorlevels ~~~~~~~~~~~ SETDATE returns the following error levels: 0 No errors (date successfully changed) 1 Some error occurred (date NOT changed) Limitations ~~~~~~~~~~~ The date range is pretty much 1 January 1980 to roughly 18 January 2038. This is a limitation of my compiler's mktime() implementation, not SETDATE. If you attempt to set the date outside of this range, you will get an error message and the system date will not be changed. Note: If you compile using DJGPP mktime() is good beyond 2038; its time_t is implemented as an unsigned 32-bit number rather than a signed 32-bit quantity. In this event the date limit is 31 December 2099; this is a DOS limitation. Miscellaneous Notes ~~~~~~~~~~~~~~~~~~~ Note that the CMOS date will be changed as well as the DOS date for MS-DOS v3.3 or later. The system time is never changed. In order for DST and other time zone information to be correctly accounted for, you should have a TZ environment variable set in your AUTOEXEC.BAT file. For example, New York users would have a TZ evar of the form set tz=EST5EDT Indiana users (who do not observe DST) would have set tz=EST5 It is not crucial to have the TZ evar (after all, SETDATE's granularity is only about 24 hours) but it will be taken into account if it is there. If not, EST5EDT will be assumed. Contact Info ~~~~~~~~~~~~ SETDATE is a public domain utility written in response to a query on Usenet. As such, expect little or no support and assume all risks. The source code is included so that you may modify the program as you wish. I only ask that you leave my name intact and acknowledge your source in any derivative work. -- Robert B. Clark ClarkWehyr Enterprises http://www.iquest.net/~rclark/ClarkWehyr.html Last updated: Fri 01-21-1900 at 13:22:41