diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c6ce5f47b..f0dfd72d56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ All notable changes to the Zowe Installer will be documented in this file. #### Minor enhancements/defect fixes +## `2.13.0` +#### Minor enhancements/defect fixes +- Enhancement: `/bin/utils/date-add.rex` utility is accepting the date formatting as combination of YY|YYYY, MM, DD and any separator. + ## `2.11.0` ### New features and enhancements diff --git a/bin/libs/certificate.sh b/bin/libs/certificate.sh index d323d4f25a..49fcc232ef 100644 --- a/bin/libs/certificate.sh +++ b/bin/libs/certificate.sh @@ -884,8 +884,8 @@ EOF fi date_add_util="${ZWE_zowe_runtimeDirectory}/bin/utils/date-add.rex" - validity_ymd=$("${date_add_util}" ${validity} 1234-56-78) - validity_mdy=$("${date_add_util}" ${validity} 56/78/34) + validity_ymd=$("${date_add_util}" ${validity} YYYY-MM-DD) + validity_mdy=$("${date_add_util}" ${validity} MM/DD/YY) # option 2 needs further changes on JCL racf_connect1="s/dummy/dummy/" diff --git a/bin/utils/date-add.rex b/bin/utils/date-add.rex index c8f3649a3e..bf6b0d120d 100755 --- a/bin/utils/date-add.rex +++ b/bin/utils/date-add.rex @@ -13,19 +13,58 @@ /* * Parameters: - * 1: how many days in the future - * 2: date format. - * For example, 1234-56-78 will be YYYY-MM-DD. - * For example, 56/78/34 will be MM/DD/YY. + * 1: days: how many days in the future or past + * negative number for past + * 2: dformat: date format + * Combination of YY|YYYY, MM and DD and (optional) any separator + * For example: YYYY-MM-DD, MM/DD/YY, DD.MM.YY, YYMMDD... * - * Example: date-add.rexx 7 1234-56-78 + * Examples: + * date-add.rex 7 YYYY-MM-DD + * date-add.rex -1 MM/DD/YY */ arg options -parse var options days format +parse upper var options days dformat -today = Date('Base') +ERR_DATE.1 = "YY or YYYY (year)" +ERR_DATE.2 = "MM (month)" +ERR_DATE.3 = "DD (day)" + +if datatype(days) \= "NUM" then do + say "ERROR: expected numeric value for days: '"days"'" + exit 1 +end +/* YYMMDD -> YYYY/MM/DD */ +if length(dformat) < 6 | length(dformat) > 10 then do + len = 'short' + if length(dformat) > 10 then + len = 'long' + say "ERROR: invalid date format: '"||dformat||"' is too "||len + exit 1 +end +else do i = 1 to 3 + if pos(word(ERR_DATE.i, 1), dformat) = 0 then do + say "ERROR: invalid date format: '"||dformat||, + "' is missing "||ERR_DATE.i + exit 1 + end +end + +today = Date("Base") target = today + days -ISOTarget = Date('Standard', target, 'Base') -result = Translate(format, ISOTarget, '12345678') -say result +ISOTarget = Date("Standard", target, "Base") + +/* ISOTarget YYYYMMDD */ +/* 12344578 => YYYY = 1234, MM = 56, DD = 78 */ + +if pos("YYYY", dformat) = 0 then + dformat = overlay("34", dformat, pos("YY", dformat)) +else + dformat = overlay("1234", dformat, pos("YYYY", dformat)) +dformat = overlay("56", dformat, pos("MM", dformat)) +dformat = overlay("78", dformat, pos("DD", dformat)) + +res = translate(dformat, ISOTarget, "12345678") +say res +exit 0