home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
dsdate.zip
/
DSDATE.DOC
< prev
next >
Wrap
Text File
|
1995-09-01
|
10KB
|
243 lines
************************* INTRODUCTION *********************************
dsDate was written by a Rexx/2 programmer for use in any Rexx-based
OS/2 application. Initially, it was written for use as a subproc in
VisPro Rexx applications as a means of creating and validating date
strings entered by VisPro application users.
Note: VisPro Rexx is a licensed trademark of Hockware, Inc.,
P.O. Box 336, Cary, NC.
This function set is PUBLIC DOMAIN. Neither payment nor licensing is
required. All users may feel free to change or enhance this
function set as desired. If enhancements are made, I would appreciate
being contacted. I'm always looking for good utility functions.
Please forward any comments to me as follows:
Dan Statkus, Laurel, Maryland
CIS 74721,1603 / Internet 74721.1603@compuserve.com
************************** DESCRIPTION **********************************
dsDate provides enhancements to all switches of the DATE() function
provided by REXX/2, and also provides additional date switches.
The dsDate function emulates ALL of the switches of the native REXX/2
DATE() function. dsDate() solves the following anamolies of the REXX/2
native function:
1) DATE() only returns data concerning the current system date.
dsDate() allows you to specify ANY date and obtain the same
information using the same optional parameters used by DATE().
If you do not provide a date, then (by default) dsDate() will
act on the current system date. See examples.
2) DATE() will generate a runtime error if you attempt to use either
the 'C' or 'J' switches in native OS/2. Personal Rexx must be
available in order for these switches to function. dsDate()
solves this problem. You may use either switch at will.
Other switches provided by dsDate() and not native to REXX/2 are:
1) dsDate()'s 'T' switch will return a full text string representation
of the supplied date; eg. "January 15, 1979".
2) DATE() has no native support to validate a date. dsDate()
provides the 'V' option to validate a date. This is very useful
with data entry applications to ensure data integrity of dates
entered by application users.
3) DATE() has no abilities to increment or compare dates. dsDate()
provides the 'I' (increment) option to add/subtract to/from a
desired date. eg. Obtain the date of the day 15 days ago or
project a date 15 days in the future.
4) dsDate() provides the 'P'(Passed) switch to calculate the number of days
between any two provided dates. eg. Return the # of days passed
between DateParam1 and Dateparam2.
5) dsDate() provides the 'Q' (Quarter) switch to calculate the quarter
of the calendar year for the given date. Returns integer (1-4).
6) dsDate() can return a Gregorian date in US format from a Julian
date using the 'G' (Gregorian) switch. This is the counterpart
to the 'J' switch of both DATE() and dsDate().
7) dsDate() can return an integer representing the week day of any
given date using its 'Y' (daY) switch. Unlike the 'W' switch
which returns a text label, the 'Y' switch will produce a
numeric suitable for calculations.
********************** DEVELOPMENT NOTES **************************
Great care was taken to ensure that all procedures are closed
so as to hide all internal tokens from applications using this
function set. Parameter passing is used whenever possible. All
sub-functions used by dsDate were named with a "!" as the last
digit of the function name to ensure that they won't trample
other, similarly named, procedures.
There is only one globally scoped token used in the entire series
of procedure calls: the "dsd!." stem. I doubt that other programmers
will use a stem of this name. If so, then either this source
must be changed, or the calling program must be changed to
eliminate this trampling.
If there is a naming conflict, a simple search and replace for the
dsd!. stem will rectify it.
**************************** SYNTAX *******************************
The syntax of the dsDate function is: dsDate(switch,parm1,parm2)
When specifying dates in the parms, the date can be supplied as
mm/dd/yy, or mm/dd/yyyy. This allows for dates not in the 1900's.
Any date of the form mm/dd/yy is assumed in the 1900's
For switches requesting a date to be returned in the form mm/dd/yy,
dd/mm/yy, or yy/mm/dd, the yy portion will be 2 digits if the year is
in the 1900's or 4 digits if not in the 1900's.
Switches:
NULL i.e. dsDate() or dsDate(,parm1) converts the date
supplied in parm1 to a text string representation of the
given date in the same format as DATE().
parm1 = a Date in the format mm/dd/yy or mm/dd/yyyy
if null, parm1 will be current date.
parm2 = not used
e.g. dsDate(,'10/06/85') returns ===> 06 Oct 1985
dsDate(,'10/06/2000') returns ===> 06 Oct 2000
B (Basedate) Emulates the B switch of DATE().
e.g. dsDate(B,'08/31/95') returns ===> 728535
C (Century) Emulates C switch of DATE() without need for Personal Rexx.
e.g. dsDate(c,'01/10/85') returns ===> 31056
dsDate(c,'01/10/1800') returns ===> 10
D (Days) Emulates D switch of DATE().
e.g. dsDate(d,'01/10/85') returns ===> 10
dsDate(d,'07/10/1800') returns ===> 191
E (European) Emulates E switch of DATE().
e.g. dsDate(e,'01/23/85') returns ===> 23/01/85
dsDate(e,'01/23/1800') returns ===> 23/01/1800
G (Gregorian) Converts Julian to GREGORIAN date, and returns the
GREGORIAN date in US format (mm/dd/yy).
parm1 = null (Julian for current date) or yyddd
yy assumed in 1900's
parm2 = not used
e.g. dsDate(G,85205) returns ===> 07/24/85
I (Increment) Returns the date +/- x days from given date.
Base date supplied in parm1, number of days (+/-) supplied in parm2.
parm1 = null (current date) or mm/dd/yy or mm/dd/yyyy
parm2 = null, 0, negative integer or positive integer
e.g. dsDate(I,,1) returns ===> next day's date
dsDate(I,'07/23/85',10) returns ===> 08/02/85
dsDate(I,'07/23/85',-5) returns ===> 07/18/85
J (Julian) Emulates the J switch of DATE() without needing Personal
Rexx.
e.g. dsDate(j,'07/23/85') returns ===> 85204
dsDate(j,'07/23/1885') returns ===> 85204
L (Local) Emulates the L switch of DATE().
e.g. dsDate(l,'08/08/95') returns ===> 08 Aug 1995
M (Month) Emulates M switch of DATE().
e.g. dsDate(m,'01/23/85') returns ===> January
dsDate(m,'07/23/1885') returns ===> July
N (Normal) Emulates the N switch of DATE().
e.g. dsDate(n,'08/08/95') returns ===> 08 Aug 1995
O (Ordered) Emulates the O switch of DATE().
e.g. dsDate(o,'07/23/85') returns ===> 85/07/23
dsDate(o,'07/23/1885') returns ===> 1885/07/23
P (Passed) Returns the number of days passed between one date and
the other. The number of days from one day to the next is
considered one (1).
parm1 = null(current date) or mm/dd/yy or mm/dd/yyyy
parm2 = null(current date) or mm/dd/yy or mm/dd/yyyy
e.g. dsDate(P,,'01/01/2000') returns ===> 5288 (possibly)
dsDate(P,'01/01/1900','01/01/2000') returns ===> 36524
dsDate(P,'01/01/2000','01/01/1900') returns ===> 36524
Q (Quarter) Returns the quarter number (1-4) of the calendar year for
the date supplied as parameter 1.
parm1 = null(current date) or mm/dd/yy or mm/dd/yyyy
parm2 not used
e.g. dsDate(Q) returns ===> 1 (assume 01/01/94-03/31/94)
dsDate(Q, '07/23/95') returns ===> 3
S (Sorted) Emulates the S switch of DATE().
e.g. dsDate(s,'07/23/85') returns ===> 19850723
dsDate(s,'07/23/1885') returns ===> 18850723
T (Text) Returns a given mm/dd/yy date as Text string.
e.g. dsDate(t,'07/23/85') returns ===> July 23, 1985
dsDate(t,'07/23/1885) returns ===> July 23, 1885
U (USA) Emulates the U switch of DATE().
e.g. dsDate(u,'07/23/85') returns ===> 07/23/85
dsDate(u,'07/23/1985') returns ===> 07/23/85
dsDate(u,'07/23/1885') returns ===> 07/23/1885
V (Valid) Validates the given date. Returns '1' if date supplied
in parm1 is valid, 0 if parm1 date is invalid.
parm1 = null (current date) or mm/dd/yy or mm/dd/yyyy
parm2 = not used
e.g. dsDate(V,'a1/01/2000') returns ===> 0
dsDate(V,'01/33/1985') returns ===> 0 (33 not valid)
dsDate(V,'07/04/1776') returns ===> 1
dsDate(V,'02/29/85') returns ===> 0 (not leap year)
dsDate(V,'02/29/84') returns ===> 1
W (WEEKDAY) Emulates the W switch of DATE().
e.g. dsDate(w,'01/01/2000') returns ===> Saturday
dsDate(w,'07/04/1776') returns ===> Thursday
Y (daY) Returns the integer number (1-7) of the day of the week for
for date specified in parm1. Sunday = 1 ..... Saturday = 7
parm1 = null (current date) or mm/dd/yy or mm/dd/yyyy
parm2 = not used
e.g. dsDate(Y,'01/01/2000') returns ===> 7 (Saturday)
dsDate(Y,'07/04/1776') returns ===> 5 (Thursday)