identification division. program-id. datetime. environment division. configuration section. repository. function all intrinsic. data division. working-storage section. 01 date-as-int pic s9(9) comp. 01 seconds pic 9(15) comp. 01 day-adjust pic s9(9) comp. 01 adjustment-in. 05 adj-period-type pic xx. 88 adj-minutes value 'MI'. 88 adj-hours value 'HR'. 88 adj-days value 'DY'. 05 adj-period pic 99. 01 output_timestamp pic x(80). 01 adjust-by pic s9(9). 88 adjust-by-minutes value 60. 88 adjust-by-hours value 3600. 88 adjust-by-days value 86400. 01 input-date-time. 05 input-date pic 9(8). 05 pic x. 05 input-time pic 9(6). linkage section. 01 input_timestamp. 05 its-len pic s9(4) comp-5. 05 input-timestamp. 10 pic x occurs 0 to 80 depending on its-len. procedure division using input_timestamp. processes section. display input_timestamp perform from-timestamp perform to-timestamp perform test after until adjustment-in = low-values move low-values to adjustment-in accept adjustment-in if adjustment-in = low-values goback end-if display adjustment-in perform adjust-seconds perform to-timestamp end-perform goback. from-timestamp. compute seconds = seconds-from-formatted-time ( 'YYYYMMDDThhmmss' input-timestamp ) move input-timestamp to input-date-time compute date-as-int = integer-of-date(input-date) display seconds ' ' date-as-int exit paragraph. to-timestamp. display formatted-date('YYYY-MM-DD' date-as-int) space formatted-time('hh:mm:ss' seconds) exit paragraph. adjust-seconds. evaluate true when adj-minutes set adjust-by-minutes to true when adj-hours set adjust-by-hours to true when adj-days set adjust-by-days to true when other move 16 to return-code stop run end-evaluate compute seconds = seconds + (adjust-by * adj-period) divide seconds by 86400 giving day-adjust remainder seconds add day-adjust to date-as-int exit paragraph. end program datetime.