$CATDT - CONVERT ASCII STRING T	MACRO M1110  21-AUG-78 21:25  PAGE 3





      1						.TITLE	$CATDT - CONVERT ASCII STRING TO DATE AND TIME

      2

      3						.IDENT	"X0001"

      4

      5					;

      6					; COPYRIGHT (C) 1976 BY DIGITAL EQUIPMENT CORPORATION,

      7					; MAYNARD, MASSACHUSETTS

      8					;

      9					; THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY ON A

     10					; SINGLE  COMPUTER  SYSTEM AND MAY BE COPIED ONLY WITH THE IN-

     11					; CLUSION OF THE ABOVE COPYRIGHT NOTICE.   THIS  SOFTWARE,  OR

     12					; ANY  OTHER  COPIES THEREOF, MAY NOT BE PROVIDED OR OTHERWISE

     13					; MADE AVAILABLE TO ANY OTHER PERSON EXCEPT FOR  USE  ON  SUCH

     14					; SYSTEM  AND TO ONE WHO AGREES TO THESE LICENSE TERMS.  TITLE

     15					; TO AND OWNERSHIP OF THE SOFTWARE SHALL AT ALL  TIMES  REMAIN

     16					; IN DIGITAL.

     17					;

     18					; THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITH-

     19					; OUT  NOTICE  AND  SHOULD NOT BE CONSTRUED AS A COMMITMENT BY

     20					; DIGITAL EQUIPMENT CORPORATION.

     21					;

     22					; DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY  FOR

     23					; THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT WHICH IS

     24					; NOT SUPPLIED BY DIGITAL.

     25					;

     26					; ANDREW C. GOLDSTEIN  16 JUN 76  17:05

     27

     28

     29	000000					SMACIT

     30

     31						.MACRO	$SAVRG

     32						JSR	R5,$SAVRG

     33						.ENDM	$SAVRG

$CATDT - CONVERT ASCII STRING T	MACRO M1110  21-AUG-78 21:25  PAGE 4





     35					;+

     36					;

     37					; *** - $CATDT	CONVERT ASCII TO DATE/TIME

     38					;

     39					; THIS ROUTINE CONVERTS AN ASCII STRING REPRESENTATION OF DATE AND/OR

     40					; TIME OF DAY TO THE STANDARD DATE/TIME REPRESENTATION. VALID SYNTAX

     41					; IS AS FOLLOWS:

     42					;

     43					; EITHER DATE, OR TIME, OR BOTH MAY BE PRESENT, SEPARATED BY A BLANK OR

     44					; TAB. TIME IS OF THE FORM "HH:MM:SS" OR "HH:MM" (24 HOUR TIME).

     45					; DATE IS OF THE FORM MM/DD/YY, MM/DD/YYYY, DD-MMM-YY, OR DD-MMM-YYYY,

     46					; WHERE DD IS NUMERICAL DAY OF MONTH, MM IS NUMERICAL MONTH, MMM

     47					; IS ABBREVIATED ALPHABETIC MONTH, YY IS YEAR - 1900, AND YYYY IS FULL

     48					; YEAR.

     49					;

     50					; INPUTS:

     51					;

     52					;	R0 = ADDRESS OF ASCII STRING

     53					;	R1 = ADDRESS OF 8 BYTE DATE/TIME BUFFER

     54					;

     55					; OUTPUTS:

     56					;

     57					;	R0 = ADDRESS OF FIRST BYTE FOLLOWING DATE/TIME STRING

     58					;	R2 = FLAGS

     59					;	   BIT 0 = 1 IF DATE NOT GIVEN

     60					;	   BIT 1 = 1 IF TIME NOT GIVEN

     61					;	   BIT 15 = 1 IF SYNTAX ERROR

     62					;	CC - C	CLEAR IF NO ERRORS

     63					;		SET IF SYNTAX ERROR

     64					;	DATE/TIME VALUE IN SPECIFIED BUFFER

     65					;	OTHER REGISTERS ARE PRESERVED

     66					;

     67					;-

     68

     69	000000				$CATDT::

     70	000000					$SAVRG				; SAVE R3,R4,R5

     71					;

     72					; THIS ROUTINE BUILDS A DATE/TIME BLOCK ON THE STACK IDENTICAL TO

     73					; THAT RETURNED BY THE GTIM$ DIRECTIVE. IT EXITS THROUGH COMMON

     74					; CODE TO CONVERT THIS INTO THE 64 BIT FORMAT.

     75					;

     76					; SAVE REGISTERS AND INITIALIZE THE BLOCK ON THE STACK

     77					;

     78	000004					PUSH R0,R1,#3,#60.		; R0, R1, RETURN R2, AND TICKS/SEC

     79	000020					THRU R1 := #7

     80	000024					  PUSH #0

     81	000030					END LOOP

     82					;

     83					; SCAN THE STRING

     84					;

     85	000034					WHILE 20(SP) NE #0		; QUIT IF BOTH DATE AND TIME SEEN

     86	000042					  $CALL $CDTB <R0>		; CONVERT FIRST NUMBER

     87	000046					  IFB R2 EQ #':			; IF COLON THIS IS A TIME

     88	000054					    IF #2 OFF.IN 20(SP) GOTO SYNTAX ; OUT IF ALREADY SEEN TIME

     89	000064					    LET 20(SP) := 20(SP) - #2	; NOTE TIME SEEN

     90	000072					    LET 6(SP) := R1		; STORE HOURS IN BLOCK

     91	000076					    $CALL $CDTB <R0>		; GET MINUTES

$CATDT - CONVERT ASCII STRING T	MACRO M1110  21-AUG-78 21:25  PAGE 4-1





     92	000102					    LET 10(SP) := R1		; STORE IN BLOCK

     93	000106					    IF R2 EQ #':		; IF FOLLOWED BY A COLON

     94	000114					      $CALL $CDTB <R0>		; GET SECONDS

     95	000120					      LET 12(SP) := R1		; AND STORE

     96	000124					    END

     97

     98	000124					  ELSE				; WASN'T TIME, MUST BE A DATE

     99

    100	000126					    IF #1 OFF.IN 20(SP) GOTO SYNTAX ; OUT IF ALREADY SEEN DATE

    101	000136					    LET 20(SP) := 20(SP) - #1	; NOTE DATE SEEN

    102	000142					    IF R2 EQ #'/		; IF FORMAT IS MM/DD/YY

    103	000150					      LET 2(SP) := R1		; STORE MONTH

    104	000154					      $CALL $CDTB <R0>		; CONVERT DAY

    105	000160					      IF R2 NE #'/ GOTO SYNTAX	; "/" MUST FOLLOW

    106	000166					      LET 4(SP) := R1		; STORE DAY

    107	000172					    ELSE			; MUST BE OTHER DATE FORMAT

    108	000174					      IF R2 NE #'- GOTO SYNTAX	; OTHER DELIMITER IS "-"

    109	000202					      LET 4(SP) := R1		; STORE DAY

    110	000206					      LET R5 := #$MONTB		; POINT TO TABLE OF MONTH NAMES

    111	000212					      LET R1 := R0		; SAVE STRING POINTER

    112	000214					      THRU R4 := #12.		; SEARCH THE MONTH TABLE

    113	000220						IFB (R0)+ EQ (R5)+

    114	000224						  IFB (R0)+ EQ (R5)+

    115	000230						    IFB (R0)+ EQ (R5)+ LEAVE LOOP ; IF IT MATCHES

    116	000234						  ELSE

    117	000236	105725 					    TSTB (R5)+		; ELSE SKIP REST OF THIS NAME

    118	000240						  END

    119	000240						ELSE

    120	000242	122525 					  CMPB (R5)+,(R5)+

    121	000244						END

    122	000244						LET R0 := R1		; BACK UP STRING POINTER

    123	000246					      END LOOP			; AND TRY AGAIN

    124						      				; NOTE THAT A BAD MONTH WILL

    125						      				; RESULT IN MONTH # 13

    126	000252					      LET 2(SP) := #13. - R4	; COMPUTE MONTH NUMBER

    127	000264					      IFB (R0)+ NE #'- GOTO SYNTAX ; CHECK DELIMITER

    128	000272					    END

    129	000272					    $CALL $CDTB <R0>		; GET YEAR

    130	000276					    IF R1 LO #100. THEN LET R1 := R1 + #1900.

    131	000310					    LET (SP) := R1		; STORE YEAR

    132	000312					  END

    133	000312					  IF R2 NE #40 AND R2 NE #11 LEAVE LOOP

    134	000326					END LOOP			; DONE IF TERMINATOR WAS NOT BLANK OR TAB

    135	000330					LET R0 := R0 - #1		; BACK UP TO TERMINATOR

    136					;

    137					; DATE AND TIME IS BUILT ON THE STACK. CHECK NUMERICAL VALUES

    138					; FOR CORRECTNESS.

    139					;

    140	000332					LET R2 := SP

    141	000334					IF #1 OFF.IN 20(SP)		; CHECK DATE IF SEEN

    142	000344					  IF (R2) LO #1859. OR (R2)+ HI #58000. GOTO SYNTAX

    143	000362					  LET R1 := (R2)+		; PICK UP MONTH

    144	000364					  IF R1 EQ #0 OR R1 HI #12. GOTO SYNTAX

    145	000400					  LET R1 :B= $DAYTB-1(R1)		; GET DAYS IN MONTH

    146	000404					  IF (R2) EQ #0 OR (R2)+ HI R1 GOTO SYNTAX

    147	000416					ELSE

    148	000420					  LET R2 := R2 + #6		; SKIP DATE CHECK

$CATDT - CONVERT ASCII STRING T	MACRO M1110  21-AUG-78 21:25  PAGE 4-2





    149	000424					END

    150										; CHECK TIME REGARDLESS

    151	000424					IF (R2)+ HIS #24. GOTO SYNTAX

    152	000432					IF (R2)+ HIS #60. GOTO SYNTAX

    153	000440					IF (R2)+ HIS #60. GOTO SYNTAX

    154					;

    155					; HAVING BUILT THE BLOCK ON THE STACK, GO TO COMMON ROUTINE TO

    156					; COMPUTE STANDARD FORMAT. (IT WILL CATCH WRONG FEB. 29.)

    157					;

    158	000446					LET 24(SP) := R0		; ADJUST RETURN R0

    159	000452					JUMPTO $CBDDT

    160					;

    161					; TO HERE ON SYNTAX ERRORS

    162					;

    163

    164	000456				SYNTAX:	LET SP := SP + #18.		; CLEAN THE STACK

    165	000462					POP R1				; RESTORE R1

    166	000464	005726 				TST (SP)+			; THROW AWAY SAVED R0

    167	000466					LET R2 := #100000		; SET ERROR BIT

    168	000472					RETURN ERROR

    169

    170

    171

    172		000001 				.END

$CATDT - CONVERT ASCII STRING T	MACRO M1110  21-AUG-78 21:25  PAGE 4-3

SYMBOL TABLE



A3    = 000004   	LBLS7 = 000010   	L23     000424R  	$CATDT  000000RG 	$R    = 177777

B0      000024R  	L0      000330R  	L3      000312R  	$CBDDT= ****** GX	$SAVRG= ****** GX

B1      000034R  	L1      000126R  	L4      000174R  	$CDTB = ****** GX	$SUPMC= 000043

B2      000220R  	L10     000240R  	L5      000272R  	$DAYTB= ****** GX	$SV$  = 000000

E0      000034R  	L11     000244R  	L6      000242R  	$DIDDO= 000000   	$T    = 000024

E1      000330R  	L12     000310R  	L7      000236R  	$EF$  = 000000   	$T1   = 000000

E2      000252R  	L13     000326R  	SYNTAX  000456R  	$E$   = 000001   	$T2   = 000023

IIII  = 177777   	L14     000420R  	TYPS0 = 000000   	$I$   = 000001   	$XXX$ = 000001

LBLS0 = 000024   	L15     000360R  	TYPS1 = 000000   	$K$   = 000001   	$Y$   = 000000

LBLS1 = 000021   	L16     000362R  	TYPS2 = 000000   	$K$L  = 000001   	$Z$   = 000000

LBLS2 = 000022   	L17     000376R  	TYPS3 = 000000   	$K$T  = 000001   	$$S   = 000002

LBLS3 = 000012   	L2      000124R  	TYPS4 = 000000   	$L    = 000003   	$$T   = 000021

LBLS4 = 000012   	L20     000400R  	TYPS5 = 000000   	$L$   = 000000   	$$TT  = 000024

LBLS5 = 000011   	L21     000414R  	TYPS6 = 000000   	$MONTB= ****** GX	.$T   = 000001

LBLS6 = 000010   	L22     000416R  	TYPS7 = 000000   	$O$   = 000000



. ABS.	000000	   000

      	000476	   001

ERRORS DETECTED:  0



VIRTUAL MEMORY USED:  11478 WORDS  ( 45 PAGES)

DYNAMIC MEMORY:  12276 WORDS  ( 47 PAGES)

ELAPSED TIME:  00:01:51

EXE$:CATDT,LIS$:CATDT/-SP=SRC$:SMAC/PA:1,DSCPRE,CATDT

