0010 H datfmt(*ISO) *********************************************************************** ** ADD DURATION ** Add a duration to a Start Date, producing an End Date value ** ** Parameter List ** - RTNCODE Pkd(7,0) Return code from call to this program ** - STARTDATE Pkd(7,0) Start date in date format specified in ** the STARTFMT parameter. ** - STARTFMT Char(10) Start date format code. ** Any 6 or 7-digit date format can be ** specified, including the following: ** *MDY, *YMD, *DMY, *JUL, *CYMD ** *CYMD is the CL format of CYYMMDD ** where C is 0 or 1 0=19 and 1=20. ** - ENDDATE Pkd(7,0) Ending date. ** The resulting date from the ADDDUR ** operation. It will be in the format ** specified in the ENDFMT parameter. ** - ENDFMT Char(10) Ending date format code. ** Any 6 or 7-digit date format can be ** specified, including the following: ** *MDY, *YMD, *DMY, *JUL, *CYMD ** *CYMD is the CL format of CYYMMDD ** where C is 0 or 1 0=19 and 1=20. ** - nDUR Pkd(7,0) Duration value. ** The resulting date from the ADDDUR ** operation. It will be in the format ** specified in the ENDFMT parameter. ** - DURFMT Char(10) Duration format code. ** All date-oriented duration codes are ** supported, including the following: ** *D, *DAY, *DAYS ** *M, *MONTH, *MONTHS ** *Y, *YEAR, *YEARS ** *W, *WEEK, *WEEKS ** There is no difference in the 3 styles. *********************************************************************** 0020 D dtStart S D 0030 D dtEnd S D 0040 D nDays S 7P 0 ** ERROR return codes 0050 D BADSTRDTE C Const(201) 0060 D BADSTRFMT C Const(202) 0070 D BADENDDTE C Const(203) 0080 D BADENDFMT C Const(204) 0090 D BADDURFMT C Const(205) *************************************** ** Input parameter list ** *************************************** 0100 D rtnCode S 7P 0 0110 D StartDate S 7P 0 0120 D StartFmt S 10A 0130 D endDate S 7P 0 0140 D endFmt S 10A 0150 D nDur S 7P 0 0160 D durFmt S 10A 0170 C *ENTRY PList 0180 C Parm rtnCode 0190 C Parm StartDate 0200 C Parm startFmt 0210 C Parm EndDate 0220 C Parm endFmt 0230 C Parm nDur 0240 C Parm durFmt ** Check the starting date for a valid date in the ** date format specified. 0250 C Select 0260 C When startFmt = '*MDY' 0270 C *MDY TEST(D) startDate 73 0280 C n73*MDY Move startDate dtStart 0290 C When startFmt = '*YMD' 0300 C *YMD TEST(D) startDate 73 0310 C n73*YMD Move startDate dtStart 0320 C When startFmt = '*DMY' 0330 C *DMY TEST(D) startDate 73 0340 C N73*DMY Move startDate dtStart 0350 C When startFmt = '*JUL' 0360 C *JUL TEST(D) startDate 73 0370 C n73*JUL Move startDate dtStart 0380 C When startFmt = '*CYMD' 0390 C *CYMD TEST(D) startDate 73 0400 C n73*CYMD Move startDate dtStart 0410 C other 0420 C eval rtncode = BADSTRFMT 0430 C return 0440 C endSL 0450 C If *IN73 0460 C eval rtncode = BADSTRDTE 0470 C return 0480 C endif ** Add the duration to the Start date giving a new End date 0490 C Select 0500 C When durFmt = '*DAYS' or 0510 C durFmt = '*D' or durFmt = '*DAY' 0520 C dtStart AddDur nDur:*DAYS dtEnd 0530 C When durFmt = '*MONTHS' or 0540 C durFmt = '*M' or durFmt = '*MONTH' 0550 C dtStart AddDur nDur:*MONTHS dtEnd 0560 C When durFmt = '*YEARS' or 0570 C durFmt = '*Y' or durFmt = '*YEAR' 0580 C dtStart AddDur nDur:*YEARS dtEnd 0590 C When durFmt = '*WEEKS' or 0600 C durFmt = '*W' or durFmt = '*WEEK' ** Multiple by 7 to convert the weeks to days 0610 C nDur Mult 7 nDays 0620 C dtStart AddDur nDays:*DAYS dtEnd 0630 C other 0640 C eval rtncode = BADDURFMT 0650 C endSL 0660 C if endFmt = *BLANKS 0670 C eval endFmt = startFmt 0680 C endIf ** Convert the new End date into the date format specified, ** return it to the caller. 0690 C Select 0700 C When endFmt = '*MDY' 0710 C *MDY Move dtEnd endDate 0720 C When endFmt = '*YMD' 0730 C *YMD Move dtEnd endDate 0740 C When endFmt = '*DMY' 0750 C *DMY Move dtEnd endDate 0760 C When endFmt = '*JUL' 0770 C *JUL Move dtEnd endDate 0780 C When endFmt = '*CYMD' 0790 C *CYMD Move dtEnd endDate 0800 C other 0810 C eval rtncode = BADENDFMT 0820 C endSL 0830 C MOVE *ON *INLR 0840 C return