Skip to content

Commit

Permalink
Formatting in general pattern (#3615)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Zeithaml <[email protected]>
Co-authored-by: Mark Ackert <[email protected]>
  • Loading branch information
Martin-Zeithaml and MarkAckert authored Oct 20, 2023
1 parent 9f5c095 commit bfc4f26
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bin/libs/certificate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
59 changes: 49 additions & 10 deletions bin/utils/date-add.rex
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bfc4f26

Please sign in to comment.