PRCUDT ;WISC/DJM/DL-DATE utility for transactions for IFCAP ;1/28/98 1445
V ;;5.0;IFCAP;**155**;4/21/95
Q
DT(C,DATE1,TIME1) ;CONVERTS TRANS DATE AND TRANS TIME INTO HUMAN READABLE FORM
; INPUT
; C THE TRANSACTION HEADER SEGMENT
;
; OUTPUT
; DATE1 THE DATE FORMATTED AS "JAN 14, 1992"
; TIME1 THE TIME FORMATTED AS "9:42:34 AM" or
; "midnight" for 00:00:00 or
; "noon" for 12:00:00
;
N AP,DATE,DAY,DAYS,II,MO,S,TIME,TOTAL,YR S DATE=$P(C,U,5),TIME=$P(C,U,6)
S S=":",YR=$E(DATE,1,4),DAY=+$E(DATE,5,7),DAYS="31^28^31^30^31^30^31^31^30^31^30^31"
S $P(DAYS,U,2)=$S(YR#400=0:29,(YR#4=0&(YR#100'=0)):29,1:28)
S TOTAL="" F MO=1:1:12 S DAY=DAY-$P(DAYS,U,MO) Q:DAY'>0 S TOTAL=TOTAL+$P(DAYS,U,MO)
S DAY=+$E(DATE,5,7)-TOTAL,YR=YR-1700,MO=$S($L(MO)=1:"0"_MO,1:MO),DAY=$S($L(DAY)=1:"0"_DAY,1:DAY),Y=YR_MO_DAY_"."_TIME D DD^%DT S DATE1=$P(Y,"@"),TIME1=$P(Y,"@",2),$P(TIME1,S)=+$P(TIME1,S)
S AP=$S($P(TIME1,S)>11:"P",1:"A")_"M" S:AP="PM"&($P(TIME1,S)>12) $P(TIME1,S)=$P(TIME1,":")-12 S:$P(TIME1,S)=0 $P(TIME1,S)=12 S:TIME1="12:00" TIME1="12 "_$S(AP="AM":"midnight",1:"noon"),AP=""
S TIME1=TIME1_$S($L(AP):" "_AP,1:"") Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRCUDT 1236 printed Nov 22, 2024@17:29:38 Page 2
PRCUDT ;WISC/DJM/DL-DATE utility for transactions for IFCAP ;1/28/98 1445
V ;;5.0;IFCAP;**155**;4/21/95
+1 QUIT
DT(C,DATE1,TIME1) ;CONVERTS TRANS DATE AND TRANS TIME INTO HUMAN READABLE FORM
+1 ; INPUT
+2 ; C THE TRANSACTION HEADER SEGMENT
+3 ;
+4 ; OUTPUT
+5 ; DATE1 THE DATE FORMATTED AS "JAN 14, 1992"
+6 ; TIME1 THE TIME FORMATTED AS "9:42:34 AM" or
+7 ; "midnight" for 00:00:00 or
+8 ; "noon" for 12:00:00
+9 ;
+10 NEW AP,DATE,DAY,DAYS,II,MO,S,TIME,TOTAL,YR
SET DATE=$PIECE(C,U,5)
SET TIME=$PIECE(C,U,6)
+11 SET S=":"
SET YR=$EXTRACT(DATE,1,4)
SET DAY=+$EXTRACT(DATE,5,7)
SET DAYS="31^28^31^30^31^30^31^31^30^31^30^31"
+12 SET $PIECE(DAYS,U,2)=$SELECT(YR#400=0:29,(YR#4=0&(YR#100'=0)):29,1:28)
+13 SET TOTAL=""
FOR MO=1:1:12
SET DAY=DAY-$PIECE(DAYS,U,MO)
if DAY'>0
QUIT
SET TOTAL=TOTAL+$PIECE(DAYS,U,MO)
+14 SET DAY=+$EXTRACT(DATE,5,7)-TOTAL
SET YR=YR-1700
SET MO=$SELECT($LENGTH(MO)=1:"0"_MO,1:MO)
SET DAY=$SELECT($LENGTH(DAY)=1:"0"_DAY,1:DAY)
SET Y=YR_MO_DAY_"."_TIME
DO DD^%DT
SET DATE1=$PIECE(Y,"@")
SET TIME1=$PIECE(Y,"@",2)
SET $PIECE(TIME1,S)=+$PIECE(TIME1,S)
+15 SET AP=$SELECT($PIECE(TIME1,S)>11:"P",1:"A")_"M"
if AP="PM"&($PIECE(TIME1,S)>12)
SET $PIECE(TIME1,S)=$PIECE(TIME1,":")-12
if $PIECE(TIME1,S)=0
SET $PIECE(TIME1,S)=12
if TIME1="12
SET TIME1="12 "_$SELECT(AP="AM":"midnight",1:"noon")
SET AP=""
+16 SET TIME1=TIME1_$SELECT($LENGTH(AP):" "_AP,1:"")
QUIT