Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ******************************************************************
- * Author: Sezen
- * Date: 12/23/2019 (Edit: 4/18/2020)
- ******************************************************************
- * OUTPUTS:
- * STANDARD TIME: 15:55:15
- * EMILY TIME: 35:51:42
- ******************************************************************
- * MORE ON EMILY TIME:
- * http://xahlee.info/kbd/happy_hacking_emily.html
- ******************************************************************
- IDENTIFICATION DIVISION.
- PROGRAM-ID. EMTIME-CONVERTER.
- ENVIRONMENT DIVISION.
- CONFIGURATION SECTION.
- REPOSITORY.
- FUNCTION ALL INTRINSIC.
- DATA DIVISION.
- FILE SECTION.
- WORKING-STORAGE SECTION.
- 01 WS-STANDARD-TIME.
- 05 WS-STANDARD-HOUR PIC 99.
- 88 HOUR-CHECK VALUE 00 THRU 23.
- 05 COL1 PIC X VALUE ':'.
- 05 WS-STANDARD-MINUTE PIC 99.
- 88 MIN-CHECK VALUE 00 THRU 59.
- 05 COL2 PIC X VALUE ':'.
- 05 WS-STANDARD-SECOND PIC 99.
- 88 SEC-CHECK VALUE 00 THRU 59.
- 01 WS-EM-TIME.
- 05 WS-EM-HOUR PIC 9(2).
- 05 PIC X VALUE ':'.
- 05 WS-EM-MINUTE PIC 9(2).
- 05 PIC X VALUE ':'.
- 05 WS-EM-SECOND PIC 9(2).
- 01 EM-TIME-TOTAL PIC 99999 VALUE 46656.
- 01 STANDARD-TIME-TOTAL PIC 99999 VALUE 86400.
- 01 DAY-PERCENT PIC 9V9(25).
- 01 EM-DAY-VAL PIC 99999.
- 01 DAY-SECONDS PIC 9(6).
- PROCEDURE DIVISION.
- DISPLAY 'Enter HH:MM:SS: '.
- ACCEPT WS-STANDARD-TIME.
- * CHECK IF VALID...
- IF NOT (HOUR-CHECK AND MIN-CHECK AND SEC-CHECK AND (
- - COL1 AND COL2 = ':'))
- THEN
- DISPLAY 'INVALID TIME ENTERED. TRY AGAIN :)'
- STOP RUN
- END-IF.
- COMPUTE DAY-SECONDS = ((WS-STANDARD-HOUR*60)*60)+(WS-STANDAR
- - D-MINUTE*60)+WS-STANDARD-SECOND.
- COMPUTE DAY-PERCENT = DAY-SECONDS / STANDARD-TIME-TOTAL.
- COMPUTE EM-DAY-VAL = EM-TIME-TOTAL * DAY-PERCENT.
- COMPUTE WS-EM-HOUR = (EM-DAY-VAL / (36*36)).
- COMPUTE WS-EM-MINUTE = (EM-DAY-VAL - (WS-EM-HOUR * (36 * 36
- - ))) / 36.
- MOVE MOD(EM-DAY-VAL, 36) TO WS-EM-SECOND.
- * CONVERT BASE-10 -> BASE-6...
- CALL 'CONV-BASE-6' USING WS-EM-HOUR.
- CALL 'CONV-BASE-6' USING WS-EM-MINUTE.
- CALL 'CONV-BASE-6' USING WS-EM-SECOND.
- * OUTPUT TO CONSOLE
- DISPLAY 'STANDARD TIME: ', WS-STANDARD-TIME.
- DISPLAY 'EMILY TIME: ', WS-EM-TIME.
- STOP RUN.
- END PROGRAM EMTIME-CONVERTER.
- *
- IDENTIFICATION DIVISION.
- PROGRAM-ID. CONV-BASE-6.
- ENVIRONMENT DIVISION.
- CONFIGURATION SECTION.
- REPOSITORY.
- FUNCTION ALL INTRINSIC.
- DATA DIVISION.
- LOCAL-STORAGE SECTION.
- 01 LS-QUO PIC Z(9) VALUE 1.
- 01 LS-REM PIC Z(9) VALUE 1.
- 01 LS-STRING REDEFINES LS-REM PIC X(9).
- 01 LS-RETURN PIC X(20) VALUE SPACES.
- LINKAGE SECTION.
- 01 L-TIME PIC 9(2).
- PROCEDURE DIVISION USING L-TIME.
- PERFORM UNTIL LS-QUO = SPACES
- MOVE 0 TO LS-QUO
- DIVIDE L-TIME BY 6 GIVING LS-QUO REMAINDER LS-REM
- * BECAUSE WE ARE USING Z, ZEROES TURN TO SPACES. REPLACE IT!
- IF LS-REM = SPACES THEN
- STRING '0', LS-RETURN INTO LS-RETURN
- ELSE
- STRING TRIM(LS-STRING),LS-RETURN INTO LS-RETURN
- END-IF
- MOVE LS-QUO TO L-TIME
- END-PERFORM.
- MOVE LS-RETURN(2:) TO LS-RETURN.
- MOVE NUMVAL(LS-RETURN) TO L-TIME.
- END PROGRAM CONV-BASE-6.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement