CHKDATE.COM Copyright (C) 19 November 1993 Robert B. Clark Revision 1.00 All rights reserved. ---------------------------------------------------------------------- Written using the A86 assembler. This program accepts a date from the command line and checks it against the current system date. This utility could be used as part of an auto- mated system preventative maintenance schedule; for example, one could schedule a full HD defrag the 15th of every month by simply checking the system date with CHKDATE in a batch file. In addition, CHKDATE with the D option can check for the day of the week (Sun..Sat) and return its value to a batch file. This could be useful in applications that you want to automate weekly as opposed to a particular month, date or year. Usage: CHKDATE [D] | mm[/]dd[[/]yy] (American version) CHKDATE [D] | dd[/]mm[[/]yy] (European version) where mm=01..12, dd=01..31 and yy=00..99. CHKDATE doesn't care how you separate mm, dd and yy--in fact, you needn't use delimiters at all if you don't want to. As far as CHKDATE is concerned, "111993", "11/19/93", and "11aaa 19\ 93" are all the same thing. If the year is not specified, CHKDATE assumes the zeroth year of the current century (1900 or 2000). I just HATE strict input formats, don't you? CHECKING FOR THE DAY OF THE WEEK: CHKDATE D If the "D" parameter (case unimportant) is the first non-space character in the command line, CHKDATE will return an errorlevel equal to the day of the week: ,===========================, | ERLV | Day of the week | |===========================| | 1 | Sunday | | 2 | Monday | | 3 | Tuesday | | 4 | Wednesday | | 5 | Thursday | | 6 | Friday | | 7 | Saturday | `===========================' Here's an example: rem First line prints on Fri and Sat; the second only on Tues if errorlevel 6 echo Have a good weekend boss! if errorlevel 2 if not errorlevel 3 echo It's Tuesday! The D parameter is exclusive; date checking will not be performed in this case. CHKDATE D works the same for both the American and European versions. CHECKING FOR A PARTICULAR MONTH, DATE AND/OR YEAR: CHKDATE mm/dd/yy When used in this mode, CHKDATE will set any one of nine errorlevels that may be used in your batch files: ,=================================================================, | ERLV | M | D | Y | American version | |=================================================================| | 0 | Yes | Yes | Yes | Month, day, year all correct. | | 1 | Yes | Yes | No | Year is incorrect. | | 2 | Yes | No | Yes | Day is incorrect. | | 3 | Yes | No | No | Day and year are incorrect. | | 4 | No | Yes | Yes | Month is incorrect. | | 5 | No | Yes | No | Month and year are incorrect. | | 6 | No | No | Yes | Month and day are incorrect. | | 7 | No | No | No | Month, day, year all INCORRECT. | | 255 | n/a | n/a | n/a | Syntax error on command line. | `=================================================================' ,=================================================================, | ERLV | D | M | Y | European version | |=================================================================| | 0 | Yes | Yes | Yes | Month, day, year all correct. | | 1 | Yes | Yes | No | Year is incorrect. | | 2 | Yes | No | Yes | Month is incorrect. | | 3 | Yes | No | No | Month and year are incorrect. | | 4 | No | Yes | Yes | Day is incorrect. | | 5 | No | Yes | No | Day and year are incorrect. | | 6 | No | No | Yes | Month and day are incorrect. | | 7 | No | No | No | Month, day, year all INCORRECT. | | 255 | n/a | n/a | n/a | Syntax error on command line. | `=================================================================' Note that the European version makes checking for a specific DAY easier than the American version. The American version requires checking errorlevels 0, 1, 4 and 5, which needs four IF-THEN checks: if errorlevel 0 if not errorlevel 2 echo Correct day. if errorlevel 4 if not errorlevel 6 echo Correct day. For the European version, the errorlevels for a day check are 0, 1, 2 and 3, which needs only two IF-THEN checks: if errorlevel 0 if not errorlevel 4 echo Correct day. If you want a task to execute the 15th of every month, then you could easily code something like this in a batch file. According to the errorlevel matrix, dates for a valid day returns errorlevels 0, 1, 4 and 5: rem The year and month below are irrelevant chkdate 011593 if errorlevel 0 if not errorlevel 2 echo Today is the fifteenth! if errorlevel 4 if not errorlevel 6 echo Today is the fifteenth! If you wanted something to execute every June 23rd, you would check for errorlevels for which M and D are true (0, 1): rem The year below is irrelevant chkdate 060193 if errorlevel 0 if not errorlevel 2 echo Happy birthday, Bob! Finally, if you desired to check for any day in September, check errorlevels for which M is true (0, 1, 2, and 3): rem The day and year are irrelevant chkdate 090100 if errorlevel 0 if not errorlevel 4 echo This is September! That's all there is to it. Stay tuned for legalese stuff below.... ---------------------------------------------------------------------- LEGALESE: I'll make it very simple. I warrant this program to take up disk space. Other than that, I assume no liability for real or imagined harm or loss of life and property. Use this utility at your own risk. Keep out of reach of children. Let's see, what else.... Oh! Almost forgot.... CHKDATE is copyrighted 1993 by Robert B. Clark, all rights reserved. This program is hereby released as FREEWARE. By FREEWARE, I mean that you may use this utility until Armageddon if you wish without compensating me. You may also disseminate this archive to the four corners of the Earth if you wish, as long the archive is COMPLETE. This does NOT mean that this program is released into the PUBLIC DOMAIN. I retain all rights to CHKDATE. Of course, I wouldn't be adverse to any donations, but let's face it: I only spent a couple of hours on this thing. If you like, drop me some e-mail and tell me if you've found a use for CHKDATE. ---------------------------------------------------------------------- SUPPORT: Ha ha! You expect support for a FREE utility? Really, if you need assistance using CHKDATE, or want to suggest some improvements for future releases (bwahahaha), contact me via e-mail: Internet E-mail: rclark@iquest.net World Wide Web : http://www.iquest.net/~rclark/ClarkWehyr.html ---------------------------------------------------------------------- REVISION HISTORY: Rev 0.00 11/19/93 Program begun; rough documentation. Rev 0.90 11/20/93 1444 bytes 11-20-93 12:40a Completed basic program. Needs major optimization; it's much too large. Rev 0.91 11/22/93 2018 bytes 11-22-93 1:48p Changed errorlevel codes so that all combinations of MM/DD/YY return meaningful, non ambiguous codes. Rev 0.93 11/22/93 1781 bytes 11-22-93 6:21p Changed number output routine to handle any 16-bit number (0..65535). Eliminated clumsy number table. Program didn't allow years after 1999; fixed. Rev 0.95 11/22/93 1781 bytes 11-22-93 7:37p (American v0.95) 1781 bytes 11-22-93 7:42p (European v0.95e) Added international support for either MM/DD/YY or DD/MM/YY style date formats. Rev 0.97 11/23/93 1867 bytes 11-23-93 4:30p (American v0.97) 1868 bytes 11-23-93 4:30p (European v0.97e) Added new command--CHKDATE D will now return the day of the week as an errorlevel Sun=1...Sat=7. Also added errorlevel text output message for visual verification. Rev 0.98 11/23/93 1867 bytes 11-23-93 7:30p (American v0.98) 1868 bytes 11-23-93 7:30p (European v0.98e) ASCII value of errorlevel was being returned instead of the number itself; fixed. Rev 1.00 11/23/93 1869 bytes 11-23-93 1:00a CHKDATE.COM (American) 1870 bytes 11-23-93 1:00a EURDATE.COM (European) FIRST RELEASE, v1.00 and v1.00e. Cleaned up documentation (some) and fiddled with the help screen in the program. ###