Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ******************************************************************
- * Author: Sezen
- * Date: 12/23/2019
- * Updated!
- ******************************************************************
- * OUTPUTS:
- * Current Standard Time: 05:15:32
- * Current Emily Time: 11:51:55
- * 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.
- WORKING-STORAGE SECTION.
- 01 WS-STANDARD-TIME.
- 05 WS-STANDARD-HOUR PIC 99.
- 88 HOUR-CHECK VALUE 00 THRU 24.
- 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-CURRENT-DATE.
- 05 CURRENT-DATE PIC 9(08).
- 05 CURRENT-TIME.
- 10 WS-CURRENT-HOUR PIC 9(2).
- 10 WS-CURRENT-MIN PIC 9(2).
- 10 WS-CURRENT-SEC PIC 9(2).
- 10 PIC 9(2).
- PROCEDURE DIVISION.
- * GRAB CURRENT TIME :)
- MOVE CURRENT-DATE TO WS-CURRENT-DATE.
- DISPLAY 'Current Standard Time: ', WS-CURRENT-HOUR, ':', WS-
- - CURRENT-MIN, ':', WS-CURRENT-SEC.
- CALL 'MAIN-COMP' USING WS-CURRENT-HOUR, WS-CURRENT-MIN, WS-
- - CURRENT-SEC.
- DISPLAY 'Current Emily Time: ', WS-CURRENT-HOUR, ':', WS-
- - CURRENT-MIN, ':', WS-CURRENT-SEC.
- DISPLAY '-----------------------------------'
- 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.
- CALL 'MAIN-COMP' USING WS-STANDARD-HOUR, WS-STANDARD-MINUTE,
- - WS-STANDARD-SECOND.
- DISPLAY 'Emily Time: ', WS-STANDARD-TIME.
- STOP RUN.
- *
- IDENTIFICATION DIVISION.
- PROGRAM-ID. MAIN-COMP.
- DATA DIVISION.
- WORKING-STORAGE SECTION.
- 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).
- LINKAGE SECTION.
- 01 LS-HOUR PIC 99.
- 01 LS-MIN PIC 99.
- 01 LS-SEC PIC 99.
- PROCEDURE DIVISION USING LS-HOUR, LS-MIN, LS-SEC.
- COMPUTE DAY-SECONDS = ((LS-HOUR*60)*60)+(LS-MIN
- - *60)+LS-SEC.
- COMPUTE DAY-PERCENT = DAY-SECONDS / STANDARD-TIME-TOTAL.
- COMPUTE EM-DAY-VAL = EM-TIME-TOTAL * DAY-PERCENT.
- COMPUTE LS-HOUR = (EM-DAY-VAL / (36*36)).
- COMPUTE LS-MIN = (EM-DAY-VAL - (LS-HOUR * (36 * 36
- - ))) / 36.
- MOVE MOD(EM-DAY-VAL, 36) TO LS-SEC.
- * CONVERT BASE-10 -> BASE-6...
- CALL 'CONV-BASE-6' USING LS-HOUR.
- CALL 'CONV-BASE-6' USING LS-MIN.
- CALL 'CONV-BASE-6' USING LS-SEC.
- EXIT.
- *
- IDENTIFICATION DIVISION.
- PROGRAM-ID. CONV-BASE-6.
- DATA DIVISION.
- WORKING-STORAGE SECTION.
- 01 WS-QUO PIC Z(9) VALUE 1.
- 01 WS-REM PIC Z(9) VALUE 1.
- 01 WS-STRING-REM REDEFINES WS-REM PIC X(9).
- 01 RETURN-STR PIC X(20).
- LINKAGE SECTION.
- 01 LS-TIME PIC 9(2).
- PROCEDURE DIVISION USING LS-TIME.
- MOVE SPACES TO RETURN-STR.
- MOVE 1 TO WS-QUO.
- PERFORM UNTIL WS-QUO = SPACES
- MOVE 0 TO WS-QUO
- DIVIDE LS-TIME BY 6 GIVING WS-QUO REMAINDER WS-REM
- * BECAUSE WE ARE USING Z, ZEROES TURN TO SPACES. REPLACE IT!
- IF WS-REM = SPACES THEN
- STRING '0',RETURN-STR INTO RETURN-STR
- ELSE
- STRING TRIM(WS-STRING-REM),RETURN-STR INTO RETURN-STR
- END-IF
- MOVE WS-QUO TO LS-TIME
- END-PERFORM.
- * HERE LIES A BUG, (2:) FIXES DUPING.
- MOVE RETURN-STR(2:) TO RETURN-STR.
- MOVE NUMVAL(RETURN-STR) TO LS-TIME.
- END PROGRAM MAIN-COMP.
- END PROGRAM CONV-BASE-6.
- END PROGRAM EMTIME-CONVERTER.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement