home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-02-15 | 46.5 KB | 1,211 lines |
- FDATE Version 6.1a Feb 14, 1992
- ===================================================================
- FDATE: a utility for date manipulation in batch files.
- ===================================================================
- Stephen Ferg 5113 N. 8th Road, Arlington, VA 22205-1201
- Voice (703) 525-2241 CompuServe 73377,1157
-
- =======================================================================
- Format:
- FDATE /Ffunc /Adate /Bdate /Iformat /Oformat
- /Nnum /Ddayofweek /Pstring /Sstring
- =======================================================================
-
-
- FDATE PARAMETERS
- ================
-
- The parameters that are required depend on the function requested.
- Parameters that are specified, but not needed, are ignored.
- Executing FDATE without any parameters displays a brief help screen.
-
- Parameters can be in any order and upper or lower case.
- Note that although format specifications are not case sensitive,
- they ARE "text sensitive". If any characters are missing,
- added, or mistyped, the format specification will be rejected.
- (A common mistake is to enter "/format" instead of "/Fformat".
- This mistake can be avoided by using the /Ff function alias.)
-
- /F requests a particular FDATE function
- If this parameter is not specified, or is specified incorrectly,
- FDATE displays a help screen. If you unexpectedly get the help
- screen displayed, you probably have omitted the /F parameter.
-
- /N number of days (always a number)
-
- /D day-of-week number (used only with W function)
-
- /A date A (for date functions)
- /B date B (for date functions)
- If the /A parameter is omitted, /Atoday is assumed.
- If the /B parameter is omitted, /Btoday is assumed.
-
- /A number A (for math functions)
- /B number B (for math functions)
-
- /I specifies format of input date(s)
- If the /I parameter is omitted, /Imm-dd-ccyy is assumed.
-
- /O specifies format of output date
- If the /O parameter is omitted, /Od1 is assumed.
-
- /L specifies language of output.
- /Lus US (American) English-language output
- /Lfr French-language output
- If the /L parameter is omitted, /Lus [American English] is assumed.
-
- /V specifies that output is to be placed in an environment variable
- rather than written to standard output (i.e. to the screen).
-
- /P specifies a prefix string for the output
- /S specifies a suffix string for the output
- Maximum length for a prefix or suffix string is 80 bytes.
- These optional parameters may always be specified or omitted.
- They must be enclosed in single quotes, double quotes, or
- square brackets
-
- Note that "whitespace" will be removed from these strings,
- so formatting of /P and /S strings cannot be controlled using
- spaces. To format strings, use periods or ASCII 255 (hex'ff')
- as filler.
-
- EXAMPLES
- FDATE /Ff /At /Od1 /P"Today is "
- FDATE /Fdif /At /B12-25-TTTT /S" days until Christmas"
- FDATE /Fdif /At /B12-25-TTTT /P"It is " /S" days 'til Xmas"
- FDATE /Ff /A05-08-TTTT /S[ -- "Buffalo Bill's" birthday]
-
-
-
- ERROR HANDLING
- ==============
-
- If FDATE detects an error:
-
- (1) it will return an errorlevel of 1 (rather than 0), and
- (2) its output will be 3 lines:
- * the word ERROR
- * a DOS batch-file ECHO statement that displays an error message
- * a DOS batch-file PAUSE statement
-
- If Fdate output is displayed directly, or redirected to NUL:
- you can detect an error by testing the errorlevel for a value of 1.
-
- If Fdate output is piped to an environment manipulation utility such
- as STRINGS or GET, the environment variable will be set to ERROR.
- Errorlevel will be set by STRINGS/GET, and will probably be 0.
- In such a case, the only way to detect an error is to test the
- environment variable for the value ERROR.
-
- If FDATE output is redirected to a batch file, which is then
- CALLed to set an environment variable, the batch file will:
- * set the environment variable to ERROR,
- * ECHO the error message, and
- * pause.
- You can detect an error by testing errorlevel for the value 1
- either before or after you CALL the batch file.
- You can detect an error by testing the environment variable for the
- value ERROR, AFTER you have CALLed the batch file.
-
- ----------------------------------------------------------------------
-
- EXAMPLE:
- rem use FDATE to check validity of year in parm %1
- Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"Received year parm: "
- if errorlevel 1 echo Year parm [%1] is not valid.
- if errorlevel 1 goto endit
-
- EXAMPLE:
- rem use FDATE to verify %1, and GET to put it into %year%
- Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy | GET ZE /V%year% >nul
- if (%year%)==(ERROR) echo Year parm [%1] is not valid.
- if (%year%)==(ERROR) goto endit
-
- EXAMPLE:
- rem use FDATE to verify %1, call a batch file to put it into %year%
- Fdate /Ff /Imm-dd-ccyy /ATT-TT-%1 /Occyy /P"@set year=">junktemp.bat
- call junktemp.bat
- del junktemp.bat
- if errorlevel 1 echo Year parm [%1] is not valid.
- if errorlevel 1 goto endit
-
- SYMBOL CONVENTIONS
- ==================
-
- The following symbols are used in specifying date formats:
-
- SYMBOL EXAMPLE MEANING
- ------ ------- -------------------------------------
- cc 19 century
- yy 93 year
- mm 02 month
- zm 2 month without leading zero
- dd 08 day
- zd 8 day without leading zero
- mn February month name
- mn3 Feb month name, first 3 characters only
- dow Tuesday day of week
- dow3 Tue day of week, first 3 characters only
- dow# 3 day of week as a number (Sunday=1, Monday = 2, etc.)
- today is a "pseudodate" representing the current date
- t is an alias for the "today" pseudodate
- hh:mm 09:05 hours and minutes
- hhmm 0905 hours and minutes
- ss 09 seconds
-
-
-
- PSEUDODATES
- ===========
-
- t (or today)
- can be used with either /A or /B, e.g. /Atoday or /At.
-
- EXAMPLE
- rem Get the date that is 90 days from today
- FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
- FDATE /Fadd /N90 /At /Omm-dd-ccyy
-
- rem determine if this year is a leapyear
- FDATE /Ff /At /OLY
-
- tt when used in place of a 2-digit DD string, will cause
- Fdate to use today's day-of-the-month.
- Example: FDATE /Ff /Imm-dd-ccyy /A01-tt-1992 /Od1
-
- tt when used in place of a 2-digit MM string, will cause
- Fdate to use today's month.
- Example: FDATE /Ff /Imm-dd-ccyy /Att-01-1992 /Od1
-
- tt when used in place of a 2-digit YY string, will cause
- Fdate to use today's year (CCYY).
- Example: FDATE /Ff /Imm-dd-yy /A01-01-tt /Od1
-
- Note that TT can NOT be used for only the YY part of a CCYY
- input year. The following, for example, is NOT valid:
- Example: FDATE /Ff /Imm-dd-ccyy /A01-01-19tt /Od1
-
- tttt when used in place of a 4-digit CCYY string, will cause
- Fdate to use today's year (CCYY).
- Example: FDATE /Ff /Imm-dd-ccyy /A01-01-tttt /Od1
-
-
- EXAMPLES:
-
- Show the first Monday in the second quarter of this year
- FDATE /Fw /Iccyymmdd /Atttt0301 /D2 /N1 /Od1 /P"First Monday in QTR#2: "
-
- Show the last Friday on/before the 15th of this month.
- FDATE /Fw /Iccyymmdd /Atttttt15 /D6 /N-1 /Od1 /P"Friday before the 15th: "
-
-
- INPUT FORMATS
- =============
-
- NOTE
- If ALL input dates are specified using the "today" pseudodate, (i.e.
- /At, /Bt) then it is not necessary to supply an input format using /I.
-
- FORMAT EXAMPLES DISCUSSION
- ------ --------- -----------------------------
- ccyymmdd 19922002
-
- mm-dd-ccyy 02-20-1992 In an input format specification, the dash
- 02/20/1992 symbols represent ANY non-numeric symbol.
-
- 2-5-1992 Leading zeros need not be present.
- 2/5/1992
-
- mm-dd-yy 02-20-92 February 2, 1992 [see below, **]
-
-
- JULIAN INPUT FORMATS
- -----------------------------------------------------------------------
- NOTE: * JJJ can actually be 1 - 4 digits
- * may include a prefix of a plus or minus ( + or - ) sign
- -----------------------------------------------------------------------
-
- ccyyjjj 1992003 Third day of 1992, i.e. Jan 3, 1992
- 19923 Third day of 1992
- tttt003 Third day of this year
- tttt3 Third day of this year
-
- yyjjj 92003 Third day of 1992
- 923 Third day of 1992
- tt003 Third day of this year
- tt3 Third day of this year
- 01003 Third day of 2001 [see below, **]
-
-
- NOTE THAT FDATE WILL ACCEPT "JJJ" OF LESS THAN 1 & MORE THAN 366.
- -----------------------------------------------------------------
-
- yyjjj tt1000 the 1000th day from beginning of this year
- tt0 last day of last year
- tt-1 next-to-last day of last year
-
- FDATE /Ff /Iccyyjjj /Od1 /A1992-1 produces... Monday December 30, 1991
- FDATE /Ff /Iccyyjjj /Od1 /A19920 produces... Tuesday December 31, 1991
- FDATE /Ff /Iccyyjjj /Od1 /A1992+1 produces... Wednesday January 1, 1992
-
- FDATE /Ff /Iccyyjjj /Od1 /A1992366 produces... Thursday December 31, 1992
- FDATE /Ff /Iccyyjjj /Od1 /A1992367 produces... Friday January 1, 1993
-
- This feature allows limited date arithmetic with ordinary business
- Julian days. For example, 90 days from tt300 can be shown by:
-
- FDATE /Ff /Iyyjjj /Att390
-
-
-
-
- FDATE'S CENTURY-ASSUMPTION ALGORITHM **
- ====================================
- If an input date is supplied in a format in which the year is
- specified without a century -- that is, as YY rather than CCYY --
- then Fdate does not automatically use the current century.
- Instead,
-
- * if YY is greater than 20, then FDATE assumes CC = 19
- * if YY is less than or equal 20, then FDATE assumes CC = 20
-
- Examples:
- 21 becomes 1921
- ...
- 99 becomes 1999
- 00 becomes 2000
- 01 becomes 2001
- ...
- 20 becomes 2020
- but then (again)
- 21 becomes 1921
-
- To put it simply, FDATE makes what would be a reasonable assumption
- about the century for someone operating in the 1990's: it looks back to
- 1921 and forward to 2020. If both I and FDATE are still alive in the
- year 2000, I'll probably update FDATE's century-assumption algorithm to
- shift it forward several decades.
-
-
- OUTPUT FORMATS
- ==============
-
- FORMAT EXAMPLES DISCUSSION
- ------ --------- -----------------------------
-
- dd-mn3-yy 08-Feb-92 CompuServe-style date
-
- ccyy 1993
- ccyymm 199302 useful for triggering monthly processing
- ccyymmdd 19930208 useful for putting current date in filename
- yymmdd 908208 useful for putting current date in filename
- mmdd 0208
- dd 08
- zd 8
-
- In the following formats, months precede days (American style)
- ------------------------------------------------------------------
- mm/dd/ccyy 02/08/1993
- mm-dd-ccyy 02-08-1993
- mm.dd.ccyy 02.08.1993 British-style dates
-
- zm/zd/ccyy 2/8/1993 no leading zeros in day or month
- zm-zd-ccyy 2-8-1993 no leading zeros in day or month
- zm.zd.ccyy 2.8.1993 British-style dates
-
- mm/dd/yy 02/08/92
- mm-dd-yy 02-08-92
- mm.dd.yy 02.08.92 British-style dates
-
- zm/zd/yy 2/8/92 no leading zeros in day or month
- zm-zd-yy 2-8-92 no leading zeros in day or month
- zm.zd.yy 2.8.92 no leading zeros in day or month
-
- In the following formats, days precede months (European style)
- ------------------------------------------------------------------
- dd/mm/ccyy 02/08/1993
- dd-mm-ccyy 02-08-1993
- dd.mm.ccyy 02.08.1993 British-style dates
-
- zd/zm/ccyy 2/8/1993 no leading zeros in day or month
- zd-zm-ccyy 2-8-1993 no leading zeros in day or month
- zd.zm.ccyy 2.8.1993 British-style dates
-
- dd/mm/yy 02/08/92
- dd-mm-yy 02-08-92
- dd.mm.yy 02.08.92 British-style dates
-
- zd/zm/yy 2/8/92 no leading zeros in day or month
- zd-zm-yy 2-8-92 no leading zeros in day or month
- zd.zm.yy 2.8.92 British-style dates
-
- ------------------------------------------------------------------
-
- Day-of-the-week output formats
- ------------------------------------------------------------------
-
- dow# 5 Sunday=1, Monday=2 .... Saturday=7.
-
- dow Thursday name of day of week
- Jeudi if /Lfr specified
-
- dow3 Thu first 3 characters of name of day of week
- Jeu if /Lfr specified
-
- mn February name of month
- Fevrier if /Lfr specified
-
- mn3 Feb first 3 characters of name of month
- Fev if /Lfr specified
-
- ------------------------------------------------------------------
-
-
- LY 0 1 if year is a leapyear, otherwise 0.
- ------------------------------------
- 365 + this number gives total
- number of days in the year.
- 28 + this number gives total
- number of days in February.
- ------------------------------------
-
- d1 Saturday, February 5, 1992
- le Samedi 5 Fevrier 1992 [/Lfr specified]
-
- t1 9:05 am
- 9:05 pm
-
- HH:MM 09:05 24-hour time, hours:minutes
- 21:05
- HHMM 0905
- 2105
-
- HH:MM:SS 21:05:30 24-hour time, hours:minutes:seconds
- HHMMSS 210530
-
- full 9:05 pm on Saturday, February 5, 1992
- 9:05 pm le Samedi 5 Fevrier 1992 [/Lfr specified]
- -----------------------------------------------------------------------
- NOTE that the following formats contain embedded spaces. Consequently
- they must be enclosed in double quotes. EXAMPLE: /O"mn zd, ccyy".
- -----------------------------------------------------------------------
- "zd mn ccyy" 5 February 1992
- "zd mn, ccyy" 5 February, 1992
- "mn3 dd ccyy" Feb 05 1992
- "mn3 dd, ccyy" Feb 05, 1992
- "mn zd, ccyy" February 5, 1992
-
-
-
- "JULIAN" OUTPUT FORMATS
- =======================
-
- FORMAT EXAMPLES DISCUSSION
- ------ --------- -----------------------------
-
- julian 27 BUSINESS "Julian date" expressed as number
- of days since January 1 of the same year.
- NOTE: with this format leading zeros are
- suppressed.
-
- CCyyjjj 1992027 Jan 27, 1992
- yyjjj 92027 "
- JJJ 027 "
- BUSINESS "Julian date" expressed as number
- of days since January 1 of the same year.
- NOTE: with these formats leading zeros are
- retained.
-
- day# 727198 TRUE "Julian date" expressed as number
- of days since January 1, 0001.
-
- minute# 33088 "Julian minutes": time expressed as number
- of minutes since midnight, January 1, 1990.
-
- second# 633088 "Julian seconds": time expressed as number
- of seconds since midnight, January 1, 1990.
-
- ----------------------------------------------------------------------
- Running FDATE with /O parameter for a "Julian time" produces a
- number based on the current time of day and the date in the /A parm.
-
- If, on January 10, 1992 at 2 pm, you run FDATE this way:
- FDATE /Ff /Atoday /Ominute#
- it will produce the Julian minute for January 10, 1992 at 2 pm.
-
- If, on January 10, 1992 at 2 pm, you run FDATE this way:
- FDATE /Ff /A01-15-1992 /Imm-dd-ccyy /Ominute#
- it will produce the Julian minute for January 15, 1992 at 2 pm.
- ----------------------------------------------------------------------
-
- DATE FUNCTIONS
- ==============
-
- FUNCTION FDATE /Ffunc /Adate /Iformat /Oformat
- -------- -------------------------------------------
- format this is a synonym for function "f"
-
- f returns /Adate in format specified by /Oformat
- Since /Aformat and /Oformat can be different, the FORMAT
- function is used to change a date from one format to another.
- Because of the wide variety of output formats, the FORMAT
- function can also be used to determine the day of week of the
- date, whether the date is in a normal or leap year, etc.
-
- EXAMPLES
- FDATE /Ff /A19920101 /Iccyymmdd /O"mn zd, ccyy"
- FDATE /Ff /Atoday /Od1
- FDATE /Fformat /Atoday /Od1
-
-
-
- FUNCTION FDATE /Ffunc /Nnumdays /Adate /Iformat /Oformat
- -------- -------------------------------------------
- add Adds /Ndays to /Adate, produces date in /Oformat format
- sub Subtracts /Ndays from /Adate, produces date in /Oformat format
-
- EXAMPLES
- FDATE /Fadd /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
- FDATE /Fsub /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
- FDATE /Fadd /N90 /Atoday /Od1
-
-
-
- FUNCTION FDATE /Ffunc /Adate /Bdate /Iformat
- -------- -------------------------------------------
- comp compares the dates specified on the /A and /B parms.
- returns when
- LT /A is less than (earlier than) /B
- EQ /A is equal to (same as) /B
- GT /A is greater than (later than) /B
-
- dif Returns number of days between /Adate and /Bdate
- Order of the two dates is not significant.
- Note that for DIF, both dates must be in the SAME
- format, the input format specified in /Iformat.
- If the two dates are not in the same format, reformat one
- of the dates using the /Ff function and
- a utility like STRINGS or GET.
-
- EXAMPLES
- FDATE /Fdif /A01-01-1992 /B11-11-1992 /Imm-dd-ccyy
- FDATE /Fdif /A11-11-1992 /B01-01-1992 /Imm-dd-ccyy
- FDATE /Fdif /Atoday /B01-01-1992 /Imm-dd-ccyy
-
-
- FUNCTION FDATE /Ffunc /Adate /Iformat /Oformat /Ddow# /Ndow-count
- -------- -----------------------------------------------------------
- w W (weekday) function.
- This function accepts a date specification in parm /A and
- returns the date of the /Nth /Day-of-the-week
- before or after /Adate. For example:
-
- If /A specifies November 14, 1992
- /D specifies the number for Thursday (i.e., 5)
- /N specifies a week count of 3
- then /Fw returns the date of the third Thursday after
- November 14, 1992. (See full example, below)
-
- Note that /N may be negative. If, in the above example, /N
- is specified as -3, then Fdate returns the date of the third
- Thursday BEFORE November 14, 1992.
-
- If the date specified on the /A parms falls on the same day
- of the week as was specified on the /D parm, then that will
- be considered to be the first date meeting that day-of-week
- criterion. That is, If November 14, 1992 fell on a
- Thursday, and if /N was 1 or -1, then the output date would
- be the same as the input date, i.e. November 14, 1992.
-
- The acceptable values for /N (number of weeks) is in
- the range of 99..-99. A value of zero (i.e. /N0) is invalid.
-
- EXAMPLES
- find date of Thanksgiving (4th Thursday in November) in 1992
- FDATE /Fw /A11-01-1992 /Imm-dd-ccyy /D5 /N4 /Od1
- returns: Thursday November 26, 1992
-
- find the beginning of the work-week (Monday, 2nd day of week)
- AFTER Thanksgiving, 1992
- FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N1 /Od1
-
- find the beginning of the work-week (Monday, 2nd day of week)
- BEFORE Thanksgiving, 1992
- FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N-1 /Od1
-
-
- MATH FUNCTIONS
- ==============
-
- FUNCTION FDATE /Ffunc /Anum /Bnum
- -------- -------------------------------------------
-
- #add returns the sum of the integers specified
- on the /A and /B parms. Can be used to calculate the
- "Julian" minute(second, date) in the future from a given
- "Julian" minute(second, date).
-
- #sub (not supported)
- no numeric subtraction operation (as such) is supported.
- Often, you will find that #dif will do what you want.
- #dif is the same as subtraction in which the smaller
- number is subtracted from the larger number; it will never
- return a negative number. If you really MUST have
- subtraction, which might return a negative result, you can
- add two numbers, one of which is a negative number.
- For example, to subtract 3 from 2:
- FDATE /F#add /A2 /B-3 [ returns: -1 ]
-
- #dif returns the difference between the integers specified
- on the /A and /B parms. Can be used to calculate the
- number of minutes(seconds, days) between two
- "Julian" minutes(seconds, dates).
-
- #comp compares the integers specified on the /A and /B parms.
- returns when
- LT /A is less than /B
- EQ /A is equal to /B
- GT /A is greater than /B
-
-
- PUTTING FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE USING /V
- ===========================================================
-
- Starting with version 6.1, Fdate supports a /V (environment variable)
- parameter. A user can use /V to tell Fdate to put its output directly
- into an environment variable. (Fdate attempts to put output into an
- environment variable in the master, rather than the local, environment.)
-
- Note that due to the complexities of manipulating the environment, /V
- may not always work. If you encounter a situation in which it does not,
- you may be able to use one of the alternative techniques described in
- the next section.
-
- /Vevar tells Fdate to put output into an environmental variable
- whose name is "evar". For example:
-
- Fdate /Ff /Vdate1
-
- will set the environment variable DATE1 to the current date. If
- you type SET at the DOS prompt, you should see something like:
-
- DATE1=Friday February 14, 1992
-
- If you specify /V without an evar name, the evar name defaults to FDATE.
-
- Example : Fdate /Ff /V
- produces: FDATE=Friday February 14, 1992
-
- If you do not use /V, Fdate output is written to standard output, that
- is, to the screen.
-
-
-
-
- PUTTING FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE WITHOUT USING /V
- ===================================================================
-
- Manipulating the environment is an incredibly tricky business. There
- are questions of the local versus master environment, the version of DOS
- you are running, and the environment under which you are running (DOS,
- Windows, Carousel). In order to keep FDATE focussed on date-related
- issues, versions of Fdate prior to 6.1 did not attempt to put output
- directly into an environment variable. Instead, FDATE's output was
- written to standard output, that is, it was displayed on the screen.
- Output could then be redirected to a batch file, or piped to a utility
- (such as STRINGS or GET), that would put the output into an environment
- variable.
-
- Starting with version 6.1, Fdate supports a /V (environment variable)
- parameter. A user can use /V to tell Fdate to put its output directly
- into an environment variable. HOWEVER.... due to the complexities of
- environment manipulation, there may be circumstances where /V doesn't
- work. These include shelling to DOS, or running under Windows,
- Carousel, etc. In such cases, you will need to fall back on more basic
- methods.
-
- One way to put FDATE's output into an environment variable is to use
- the /P (prefix string) feature to create a DOS "SET" statement,
- redirect the output to a batch file, and CALL the batch file.
- Since CALL first appeared in DOS 3.3, you will need DOS 3.3 or
- greater to use this technique.
-
- FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
- call JUNKTEMP.BAT
- del JUNKTEMP.BAT
-
- There are also shareware and public domain utilities that are written
- specifically to manipulate environment variables, and do that job very
- well. FDATE's output can be put into an environment variable by piping
- it to one of these utilities. When piping FDATE output to a utility,
- you can prevent the output from being ECHOed to the screen by
- redirecting the output to NUL.
-
- EXAMPLE: use STRINGS to put date into DATE1 environment variable
- FDATE /Ff /At /Od1 | STRINGS date1= ASK >NUL
-
- -----------------------------------------------------------------
- I recommend Bob Stephan's GET and PC Magazine's STRINGS.
-
- As of February 14, 1992, the current version of GET is 2.5.
- On CompuServe, use IBMFF to look for GET*.ZIP (e.g. GET25.ZIP for
- version 2.5) in CIS:IBMSYS, or for GET.ZIP in ZNT:UTILFORUM, lib 16.
- GET is also available from the Public Software Library in Houston.
-
- As of February 14, 1992, the current version of STRINGS is 1.3.
- On CompuServe, look for STRING.ZIP in the PC Magazine Utilities
- Lib of ZNT:UTILFORUM. STRHYP.ZIP contains good hypertext
- documentation on STRINGS.
- -----------------------------------------------------------------
-
- =======================================================================
- EXAMPLE #1
- Redirect FDATE output to a file, or to a callable batch file,
- or pipe it to STRINGS or GET to store it in an environment variable
- =======================================================================
- rem display Fdate output on screen
- FDATE /Ff /At /Od1 /P"Today is "
-
- rem Redirect FDATE output to a file
- FDATE /Ff /At /Od1 /P"Today is " >FDATE.OUT
-
- rem Redirect FDATE output to a callable batch file
- FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET DATE1=" >JUNKTEMP.BAT
- call JUNKTEMP.BAT
- del JUNKTEMP.BAT
-
- rem Pipe FDATE output to STRINGS to store it in DATE1 environment var
- FDATE /Ff /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
-
- rem Pipe FDATE output to GET to store it in DATE1 environment var
- FDATE /Ff /Atoday /O"mn zd, ccyy" |GET ZE /Vdate1 >NUL
-
-
-
- =======================================================================
- EXAMPLE #2
- Find the difference (in days) between two dates in different formats
- Use GET to put FDATE output into environment variables.
- =======================================================================
- set date1=05-10-1992
-
- rem reformat date literal into same format as date1
- FDATE /Ff /Imm-dd-yy /A05-08-92 /Omm-dd-ccyy | GET ZE /Vdate2>NUL
-
- rem get difference between date1 and date2
- FDATE /Fdif /Imm-dd-ccyy /A%date1% /B%date2%| GET ZE /vdiff>NUL
-
- echo The difference is %diff% days.
-
-
-
-
- =======================================================================
- EXAMPLE #3
- Schedule a program to run at a specified time in the future. Note that
- this involves a lot of disk activity because DOS re-reads the batch
- file from disk every time it does a GOTO LOOPTOP. If you do this, it
- is a good idea to run the batch file from a RAM DISK.
- =======================================================================
- REM GET CURRENT JULIAN MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
- FDATE /Ff /At /Ominute# |STRINGS RunTime= ASK >NUL
-
- REM ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
- FDATE /F#add /A%RunTime% /B120 |STRINGS RunTime= ASK >NUL
-
- REM LOOP UNTIL NOWTIME HAS REACHED RUNTIME
- :LoopTop
- FDATE /Ff /At /Ominute# |STRINGS NowTime= ASK >NUL
- FDATE /F#comp /A%NowTime% /B%RunTime% |STRINGS TimeComp= ASK >NUL
- if (%TimeComp%)==(LT) goto loopTOP
- :LoopEnd
-
- echo STARTING EXECUTION OF APPLICATION: [program name]
-
-
-
- =======================================================================
- EXAMPLE #4
- Rename file BACKUP.LOG to a name that contains today's date
- =======================================================================
- FDATE /Ff /Atoday /Oyymmdd /P"@SET DATE1=" >JUNKTEMP.BAT
- call JUNKTEMP.BAT
- del JUNKTEMP.BAT
- ren BACKUP.LOG BK%DATE1%.LOG
- SET DATE1=
-
-
-
- =======================================================================
- EXAMPLE #4b
- Use FDATE to rename a log file to a name that will be unique within a
- minute time-frame. This is a way to keep an historical record of a
- series of log files. Since the file will retain its original date/time
- stamp, you will still be able easily to tell when it was created.
- In this example, we use GET to put the FDATE output into
- environment variable TEMPVAR.
- =======================================================================
- FDATE /FF /At /Ominute# | GET ZE /Vtempvar >nul
- REN online.log %tempvar%.log
- SET tempvar=
-
-
-
- =======================================================================
- EXAMPLE #5
- Find calendar date corresponding to Julian date 1992:045
- =======================================================================
- FDATE /Ff /A1992045 /Iccyyjjj /Od1
-
-
-
- =======================================================================
- EXAMPLE #6
- Check to see if parameter %1 is a valid year (CCYY)
- =======================================================================
- @echo off
- rem determine if value sent in through parameter %1 is a valid year
- Fdate /Ff /Imm-dd-ccyy /A01-01-%1 /Od1 >nul
- if errorlevel 1 echo Parm 1 was not a valid year: %1
- if errorlevel 1 goto endit
-
- echo PUT YOUR BATCH PROCESSING HERE, USING YEAR VALUE OF: %1
-
- :endit
-
-
-
- =======================================================================
- EXAMPLE #7
- Find the 4th Thursday in November (Thanksgiving)
- =======================================================================
- Fdate /Fw /D5 /N4 /A11-01-%year% /Imm-dd-ccyy /Od1 /P"Thanksgiving: "
-
-
-
- =======================================================================
- EXAMPLE #8
- Show the number of the anniversary for some special event.
- =======================================================================
- SEE HOLIDAYS.BAT
-
-
- =======================================================================
- EXAMPLE #9
- Run a program once a day, when you boot for the first time that day.
- =======================================================================
- @echo off
- cls
-
- REM -------------------------------------------------------------------
- REM Run daily processing once a day. Put this code in AUTOEXEC.BAT.
- REM This batch file requires DOS 3.3+, since it uses CALL.
- REM -------------------------------------------------------------------
- if not exist LastRun.BAT goto RunNow
- REM LastRun.Bat will set env var LASTRUN to date AUTOEXEC was last run.
- call LastRun.BAT
-
- REM Compare today's date to date in LASTRUN
- Fdate /Fcomp /Imm-dd-ccyy /At /B%LastRun% /P"@set COMP=">junktemp.BAT
- call junktemp.BAT
- del junktemp.BAT
-
- IF (%COMP%)==(EQ) goto NoRun
- REM if user reset system clock, today's date may be less than LASTRUN
- IF (%COMP%)==(LT) goto NoRun
-
- rem Daily processing hasn't been run today. Run it.
-
- echo RUNNING ONCE A DAY PROCESSING: Job 1
- echo RUNNING ONCE A DAY PROCESSING: Job 2
- echo RUNNING ONCE A DAY PROCESSING: ............. etc.
-
- rem ------------------------------------------------------------------
- rem Save today's date in a new version of LastRun.BAT
- rem Note that this will be executed only if daily processing runs to
- rem completion without hanging the machine or aborting the batch file.
- rem ------------------------------------------------------------------
- Fdate /Ff /Omm-dd-ccyy /At /P"@set LastRun=">LastRun.BAT
-
- :NoRun
- set LastRun=
- set COMP=
-
- FDATE'S ALGORITHMS
- ==================
-
-
- FDATE IS DESIGNED FOR BUSINESS, NOT HISTORICAL, APPLICATIONS
- ============================================================
- FDATE is intended for business applications, not historical ones.
- As far as FDATE is concerned, the calendar has followed the same
- pattern, unchanged, since January 1, 0001.
- -------------------------------------------------------------------
- FDATE does not take into account historical changes in the calendar
- such as the glitch in English dates that occurred when Britain
- moved from the Julian to Gregorian calendar in the 18th century,
- or Russia made the same move in the early 20th century.
- -------------------------------------------------------------------
-
-
- FDATE'S BASE DATE
- =================
- Internally, date manipulations are based on translating a calendar
- date into an "absolute" or "TRUE Julian" date: a date expressed
- as the number of days from some day in the distant past.
- FDATE's base date is January 1, 0001 (i.e. day 1 of month 1 of year 1)
- FDATE's absolute date for January 1, 0001 is 1.
- FDATE's absolute date for January 1, 1992 is 727198.
-
-
- FDATE'S LEAP YEAR ALGORITHM
- ===========================
- Every year evenly divisible by 4 IS a leap year
- EXCEPT THAT
- Every year evenly divisible by 100 IS NOT a leap year
- EXCEPT THAT
- Every year evenly divisible by 400 IS a leap year
- .
- Using this algorithm
- 1983 is not a leap year
- 1984 is a leap year
- 1900 is not a leap year
- 2000 is a leap year
-
- See "A Machine Algorithm for Processing Calendar Dates", by
- Henry F. Fliegel (Georgetown University Observatory) and
- Thomas C. Van Flandern (U.S. Naval Observatory)
- COMMUNICATIONS OF THE ACM, Volume 11, Number 10, October 1968
-
- There is supposedly a new adjustment to the leapyear algorithm,
- which specifies the additional exception:
-
- EXCEPT THAT
- Every year evenly divisible by 4000 IS a leap year
-
- See "Bit By Bit" column, COMPUTER LANGUAGE, November 1989, p. 148.
- This adjustment is not part of FDATE's leapyear algorithm.
- Unless your application is working with dates 2,000 years in the
- future, the lack of this exception will be irrelevant for you.
-
- DEMONSTRATION BATCH FILES
- =========================
- FDATE ships with a number of demonstration batch files. These are
- sample applications that illustrate some of the ways that FDATE
- might be used to build applications. They can be studied for
- ideas for ways of using FDATE. They can also be used "as is", or
- copied and customized to build applications that meet your own
- special needs.
-
-
-
-
-
- DEMONSTRATION BATCH FILE: HOLIDAYS.BAT
- ======================================
-
- HOLIDAYS without any parameters displays events in current year.
- HOLIDAYS with a year parameter displays events in that year.
-
- EXAMPLE: HOLIDAYS displays events in current year
- EXAMPLE: HOLIDAYS 1999 displays events in year 1999.
-
- As the holidays are displayed, you can dump each screen display
- to a printer by pressing SHIFT+PRINTSCREEN.
-
-
-
- DEMONSTRATION BATCH FILE: ALARM
- ===============================
- ALARM.BAT is like a simple alarm clock for your PC. ALARM.BAT waits
- until a specified time, then triggers an alarm: it beeps and displays a
- message. It continues until someone presses CONTROL-BREAK.
-
- If you enter just "ALARM" at the DOS prompt, without any parameters,
- ALARM displays a HELP screen that shows how to use it.
-
- ALARM uses ANSI control codes to control screen color and cursor
- placement, so it requires ANSI.SYS in order to work properly.
- If you are not using ANSI.SYS, it will display some garbage
- characters on your screen unless you modify the batch file to remove
- the ANSI control codes.
-
- USAGE : ALARM shows current time in hhmm format
- USAGE : ALARM hhmm [msg] waits until hhmm, then sounds an alarm
-
- EXAMPLE : ALARM 0930 [sounds alarm at 9:30 am]
- EXAMPLE : ALARM 930 Staff meeting [sounds alarm at 9:30 am]
- EXAMPLE : ALARM 1800 [sounds alarm at 6:00 pm]
-
- For midnight, specify 0000 or 2400 for hhmm.
- EXAMPLE : ALARM 2400 START MIDNIGHT BATCH RUN
-
- The first thing that ALARM.BAT does is to change to the M: drive. M:
- is presumed to be a RAM disk. Before you can use ALARM.BAT, you
- should use your favorite text editor to change the RAM disk designation
- to point to your own RAM disk. It is possible to run ALARM.BAT from a
- normal hard disk or floppy, but because ALARM.BAT does a LOT of disk
- activity, it is strongly recommended that you make your current
- directory a RAM disk before running it.
-
- To prevent repeated disk accesses to find the FDATE program, you
- should also have FDATE on the RAM disk, or be using a cache.
-
- USING ALARM TO CREATE RUN-IT
- ============================
-
- You can copy ALARM.BAT to another batch file (say, RUN-IT.BAT) and
- modify it so that rather than sounding an alarm it triggers other
- activiites instead: runs a program or programs, or chains to another
- batch file, for example.
-
- To create a generalized RUN-IT.BAT, you could use the words of the
- message to pass in the name of a batch file that you want to be run at
- a certain time, along with its parameters. Make the triggered activity
- this:
-
- rem Note that earlier SHIFT has moved batch file name to parm 1.
- rem run %1 batch file.
- %1 %2 %3 %4 %5 %6 %7 %8 %9
-
- Then entering this at the DOS prompt:
-
- RUN-IT 0001 BACKUP.BAT C: D: E:
-
- would cause RUN-IT to wait until 1 minute past midnight, then
- run a batch file called BACKUP.BAT to backup drives C:, D:, and E:.
-
-
- DEMONSTRATION BATCH FILE: TIC.BAT
- =================================
-
- TIC.BAT is a sample application that uses FDATE to create a "tickler
- file" batch file. The default name for the file is C:\TICKLER.BAT.
-
- In order to use TIC on a regular basis, you should:
-
- * Use your favorite text editor to modify TIC.BAT so that it
- will use your favorite text editor in the EDIT function.
- (TIC.BAT ships with the editor set to SPFPC).
-
- * If you wish, use your favorite text editor to modify the
- first few lines of TIC.BAT, so the "SET TicBAT=" statement
- sets TicBAT to a different file name for the tickler batch file.
- Note that you must specify the full filename,
- including path and extension.
-
- * Put TIC.BAT in a directory that is in your PATH.
-
- * add the following lines to your AUTOEXEC.BAT file:
-
- CLS
- rem show today's appointments
- call TIC T
- echo.
-
- rem show tomorrow's appointments [note space betwee T and +1]
- call TIC T +1
- echo.
-
- pause
-
- This will cause the tickler batch file to be run when you
- boot your computer, showing you your scheduled appointments.
-
- HELP
- ====
- Running TIC without any parms will cause it to display a HELP screen.
- EXAMPLE: tic
-
-
- ADDING A NEW TICKLE (SINGLE DATES)
- ==================================
- To add a new SINGLE DATE tickle, invoke TIC. The first parm must be the
- date of the desired tickle, in the format mm/dd/yy. (You may use the
- pseudodate TT for the current month or year, if you wish.)
-
- This parm must be followed by a description of the appointment.
- * If no description is entered, TIC interprets the date in parm 1
- as a request to display the tickles for that date.
- NOTE: DOS batch files strip commas out of their input parameters, so
- any commas in your description will be lost.
-
- EXAMPLE: tic 5/5/92 Cinco de Mayo party w/ Susan: El Charro @ 6pm
- EXAMPLE: tic 5/5/tt Cinco de Mayo party w/ Susan: El Charro @ 6pm
-
-
- ADDING A NEW TICKLE (REGULAR WEEKLY APPOINTMENTS)
- =================================================
- To add a new REGULAR APPOINTMENT tickle, invoke TIC. The first two
- parms must be the string "dow" (or "DOW") and the day-of-the-week
- number of the day of the week (e.g. 2 for Monday).
-
- These parms should be followed by a description of the appointment.
-
- EXAMPLE: tic dow 2 Regular Monday morning staff meeting @ 8:30 am
- EXAMPLE: TIC DOW 6 STANDING TENNIS DATE WITH JANICE AT 6:30
-
-
- CHECKING YOUR TICKLES
- =====================
- You can check your tickler file appointments for a particular day at
- any time by invoking TIC with only a date parm or the pseudodate T or
- TODAY.
-
- EXAMPLE: tic t displays appointments for today
- EXAMPLE: tic today displays appointments for today
- EXAMPLE: tic 5/5/92 displays appointments for May 5, 1992
- EXAMPLE: tic 5/5/tt displays appointments for May 5 of this year
- EXAMPLE: tic tt/5/tt displays appointments for the 5th of this month
-
- You can check your tickler file appointments for a date from one to
- seven days in the future by invoking TIC with two parms: T (for today)
- followed by a number of +1 through +7. Unsigned numbers are treated
- as if they have a plus sign. Negative numbers will show appointments
- for days in the past.
-
- EXAMPLE: tic t displays appointments for today
- EXAMPLE: tic t 1 displays appointments for tomorrow
- EXAMPLE: tic t +1 displays appointments for tomorrow
- EXAMPLE: tic t +7 displays appointments for a week from today
- EXAMPLE: tic t -1 displays appointments for yesterday
-
- Note that the space between the first parm "T" and the second, number
- parm, is required:
-
- EXAMPLE: tic t+2 does not recognise "t+2" as "t +2".
- Displays appointments for TODAY.
-
- If the tickler batch file does not exist, nothing will be displayed.
-
- REMOVING DEAD TICKLES
- =====================
- After a while the tickler batch file will become very long, filled with
- "dead tickles". You can edit it with a text editor to remove the dead
- tickles:
-
- EXAMPLE: tic edit
- EXAMPLE: TIC ED
-
- or simply delete it and let TIC create a new one the next time
- you use TIC to add a tickle.
-
- USE AND DISTRIBUTION OF FDATE
- =============================
-
- FDATE is freeware, or what is known as "zero-cost shareware".
- FDATE is not what is technically called "public domain" software
- because the author retains the copyright. FDATE can, however,
- be copied, used, and distributed freely as long as both FDATE.EXE
- and its associated doc file (FDATE.DOC) and its demonstration batch
- files (FDATEX.BAT, HOLIDAYS.BAT, TIC.BAT, ALARM.BAT) are not altered
- and are distributed together.
-
- FDATE can be included in shareware packages as long as both FDATE and
- its related files are included in the shareware package.
-
- If you have received FDATE as part of some larger shareware package,
- please be aware that you may freely use, copy, and distribute FDATE
- without paying a fee for, or registering, the larger package.
-
- The author explicitly disavows any claim whatsoever about the
- correctness or functionality of FDATE, its documentation, and its
- demonstration batch files, and disclaims liability for anything and
- everything bad that might happen in connection with, before, during, or
- after using it. I have tried to make FDATE work right, but everybody
- makes mistakes, so you use FDATE at your own risk.
-
- I don't know if people will find FDATE useful, and I'd like to find
- out. If you find FDATE useful and use it on a regular basis, I'd
- appreciate it if you would drop me a short note via US mail or
- CompuServe, telling me about how you are using FDATE.
-
- If you need other input/output formats, or if you need a different
- leapyear algorithm, please contact the author.
-
-
-
-
- UPDATES AND CURRENT VERSION OF FDATE
- ====================================
-
- You will always be able to find the most recent version of FDATE on
- CompuServe. The filename will be FDATE.ZIP, and it will be available in
- one of the libraries in the CIS:IBMSYS forum and one of the libraries in
- the ZNT:UTILFORUM forum. You can find it by using cross-library
- searching, looking for the filename FDATE.ZIP or the keyword FDATE.
-
- Feel free to post copies of FDATE.ZIP on any BBS that you wish, but
- please do not upload it to any CompuServe library. As long as I am the
- only one putting copies of FDATE onto CompuServe, we can keep confusion
- over versions to a minimum.
-
- The current distribution package (FDATE.ZIP) contains the following:
-
- FDATE.EXE [the FDATE program]
- FDATE.DOC [this file, documentation for FDATE]
-
- FDATEX.BAT [demonstration batch files]
- HOLIDAYS.BAT
- TIC.BAT
-
-
- FDATE REVISION HISTORY
- ======================
-
- Letters appended to version numbers indicate modifications to
- the doc files, without any modification to the FDATE.EXE software.
- Asterisks (*) indicate most important changes in the new version.
-
- 1.1 Oct 01, 1991
- First version of FDATE
-
- 3.0a Dec 27, 1991
- * =============== MAJOR BUG FIX ==============================
- * Fixed bug in TRUEDATE date arithmetic routine that caused
- * incorrect dates to be returned for the last 2 or 3 days of
- * some months.
-
- 3.1a Dec 28, 1991
- Fixed bug: error messages were ignoring the /P parm
-
- 4.2b Jan 06, 1992
- In HOLIDAYS.BAT:
- Fixed bug in algorithm for Ash Wednesday
- Corrected algorithm for Advent (thanks to L. Schliesser)
-
- 4.4b Jan 22, 1992
- In TIC.BAT:
- Fixed ability to list by date, which had been messed up when
- adding ability to accept +1, etc. as parms
-
- 4.6a Jan 27, 1992
- Fixed problem that prevented output from being redirected in
- version 4.5
-
- 5.1a Feb 09, 1992
- * Added julian INPUT formats yyjjj and CCyyjjj
- Added documentation on Fdate's century-assumption algorithm
-
- 5.2a Feb 10, 1992
- Relaxed the requirement that dates in JJJ must be zero-filled
- on the left to occupy all 3 digits. JJJ can now be as
- little as 1 character long, and as many as 4 characters.
-
- 5.3a Feb 13, 1992
- Replaced "eng" language parameter with "us", in case
- there might be a need to distinguish American-style
- dates from British-style dates in the future.
-
- 6.1a Feb 14, 1992 *** MAJOR ENHANCEMENT ***
- * Added /V parm, which allows a user to have Fdate itself set an
- environment variable, rather than setting Evar by piping or
- redirecting Fdate's standard output.
-
- Added output formats MN (monthname) and MN3
- Added demo batch file DO-ONCE.BAT to fdate distribution ZIP file
-
- Modification log was getting very long, so deleted all docs on
- modifications before version 5.0 except for documentation of
- bug fixes.