.TITLE CDATAI .IDENT /V01/ .ENABLE LC ; ; This module forms part of the suite of Date Routines returning the ; current date in one of the following forms, or converting one form to ; another. ; Form I - Day, Month & Year since 1950 as 3 byte values ; Form A - ASCII DD-MMM-YY ; Form D - Integer*2 days since 1st January 1950 ; Form E - Integer*2 encoded date ; Form W - Weekday Number (0 = Sunday) ; ; Author: V01 14-Jul-80 Phil Stephensen-Payne ; ; Calling Sequence: ; ; This subroutine is called via the standard FORTRAN calling sequence as: ; ; CALL CDATAI (DATE,DAY,MONTH,YEAR [,STATUS]) ; or ; STATUS = CDATAI (DATE,DAY,MONTH,YEAR) ; ; or ; CALL CDATAI from MACRO-11 with ; R5 = 0 ; R1 = Address of DATE ; R1 = DAY on output ; R2 = MONTH on output ; R3 = YEAR on output ; R0 = STATUS on output ; ; Where: ; DAY = Number of day (1-31) ; MONTH = Number of month (1-12) ; YEAR = Year since 1950 (1950=0) ; DATE = ASCII Date in form DD-MMM-YY ; STATUS = Optional error return ; ; Errors returned: ; ; STATUS = 0 if the operation was successful ; = -1 if a parameter error was detected ; = -2 if an invalid input date was specified ; ; External references: ; ; This module calls the subroutines PRMCHK ; ; BUF: .BLKW 2 ; To hold date MONTAB: .RAD50 /DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJAN/ ; ; CDATAI:: TST R5 ; Called directly from MACRO-11? BEQ 20$ ; If eq yes - omit PRMCHK ; ; Specify number of parameters including error return. R5 not affected. ; MOV #5,R0 ; Check Number of Parameters CALL PRMCHK ; BCC 10$ ; If CC parameters OK - carry on JMP END ; Else error - exit immediately ; 10$: TST (R5)+ ; Ignore Number of parameters MOV (R5)+,R1 ; Get address of input ; 20$: MOV R1,R0 ; Propagate input address MOV #6,R2 ; Only interested in first six (DD-MMM) CALL $CVTUC ; Convert those to upper case SUB #6,R0 ; Reset address of buffer CALL $CDTB ; Convert day number to binary MOV R1,BUF ; Store it CMPB R2,#'- ; Valid terminator? BNE ERR ; If NE no - invalid date CALL $CAT5 ; Convert next three to RAD50 MOV #MONTAB,R3 ; Get address of month table MOV #12.,R2 ; Twelve months to check ; 30$: CMP R1,(R3)+ ; This month? BEQ 40$ ; If EQ yes - store it SOB R2,30$ ; No - check next one BR ERR ; No such month - error ; 40$: MOV R2,BUF+2 ; Store month number CMPB (R0)+,#'- ; Valid terminator? BNE ERR ; If NE no - error CALL $CDTB ; Yes - convert year MOV R1,R3 ; Put year in right register MOV BUF+2,R2 ; Get month back MOV BUF,R1 ; and year CALL CDCHKI ; Check the date is OK BCS ERR ; If CS it wasn't - error TST R5 ; Called from MACRO-11 BEQ 50$ ; If eq yes - we're finished MOVB R1,@(R5)+ ; No - return the answer MOVB R2,@(R5)+ ; MOVB R3,@(R5)+ ; ; 50$: CLR R0 ; END: RETURN ; ERR: MOV #-2,R0 ; Invalid date RETURN ; .END