XBDIFF ; IHS/ADC/GTH - RETURN DIFFERENCE BETWEEN TWO DATE/TIMES ; [ 02/07/97 3:02 PM ]
;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
;
; Passed two date/times this routine returns the difference
; in days, hours, minutes, seconds separated by colons ":".
;
; The date/times must be passed in the variables X and X1.
; The result will be returned in X. X1 will be killed.
;
; If either X or X1 are invalid X will be returned as -1 and
; X1 will be killed.
;
; The date/times may be passed in $HOROLOG format or in
; internal FileMan format.
;
; See also, $$FMDIFF^XLFDT, and $$HDIFF^XLFDT.
;
START ;
NEW A,B,C,D,E,F,G
D EDIT
Q:X<0
S:X>X1 A=X,X=X1,X1=A
I X?5N1","5N S A=$P(X,",",1),B=$P(X,",",2) I 1
E D H^%DTC S A=%H,B=%T
I X1?5N1","5N S C=$P(X1,",",1),D=$P(X1,",",2) I 1
E S X=X1 D H^%DTC S C=%H,D=%T
S E=C-A S:D<B E=E-1,D=D+86400 S D=D-B,F=D\3600,D=D-(F*3600),G=D\60,D=D-(G*60)
S X=E_":"_F_":"_G_":"_D
KILL %H,%T,%Y,A,B,C,D,E,F,G,X1
Q
;
EDIT ; EDIT INPUT
D EDITX
Q:X<0
D EDITX1
Q:X<0
I X?5N1"."5N D Q
. I $P(X,".",2)>86399 S X=-1 KILL X1
. Q
S A=$P(X,".",2)
I +$E(A,1,2)<24,+$E(A,3,4)<60,+$E(A,5,6)<60 Q
E S X=-1 KILL X1
KILL A
Q
;
EDITX ; EDIT X
Q:X?5N1"."5N
Q:X?7N
Q:X?7N1"."1.6N
S X=-1
KILL X1
Q
;
EDITX1 ; EDIT X1
Q:X?5N1"."5N
Q:X?7N
Q:X?7N1"."1.6N
S X=-1
KILL X1
Q
;
XBDIFF ; IHS/ADC/GTH - RETURN DIFFERENCE BETWEEN TWO DATE/TIMES ; [ 02/07/97 3:02 PM ]
+1 ;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
+2 ;
+3 ; Passed two date/times this routine returns the difference
+4 ; in days, hours, minutes, seconds separated by colons ":".
+5 ;
+6 ; The date/times must be passed in the variables X and X1.
+7 ; The result will be returned in X. X1 will be killed.
+8 ;
+9 ; If either X or X1 are invalid X will be returned as -1 and
+10 ; X1 will be killed.
+11 ;
+12 ; The date/times may be passed in $HOROLOG format or in
+13 ; internal FileMan format.
+14 ;
+15 ; See also, $$FMDIFF^XLFDT, and $$HDIFF^XLFDT.
+16 ;
START ;
+1 NEW A,B,C,D,E,F,G
+2 DO EDIT
+3 IF X<0
QUIT
+4 IF X>X1
SET A=X
SET X=X1
SET X1=A
+5 IF X?5N1","5N
SET A=$PIECE(X,",",1)
SET B=$PIECE(X,",",2)
IF 1
+6 IF '$TEST
DO H^%DTC
SET A=%H
SET B=%T
+7 IF X1?5N1","5N
SET C=$PIECE(X1,",",1)
SET D=$PIECE(X1,",",2)
IF 1
+8 IF '$TEST
SET X=X1
DO H^%DTC
SET C=%H
SET D=%T
+9 SET E=C-A
IF D<B
SET E=E-1
SET D=D+86400
SET D=D-B
SET F=D\3600
SET D=D-(F*3600)
SET G=D\60
SET D=D-(G*60)
+10 SET X=E_":"_F_":"_G_":"_D
+11 KILL %H,%T,%Y,A,B,C,D,E,F,G,X1
+12 QUIT
+13 ;
EDIT ; EDIT INPUT
+1 DO EDITX
+2 IF X<0
QUIT
+3 DO EDITX1
+4 IF X<0
QUIT
+5 IF X?5N1"."5N
Begin DoDot:1
+6 IF $PIECE(X,".",2)>86399
SET X=-1
KILL X1
+7 QUIT
End DoDot:1
QUIT
+8 SET A=$PIECE(X,".",2)
+9 IF +$EXTRACT(A,1,2)<24
IF +$EXTRACT(A,3,4)<60
IF +$EXTRACT(A,5,6)<60
QUIT
+10 IF '$TEST
SET X=-1
KILL X1
+11 KILL A
+12 QUIT
+13 ;
EDITX ; EDIT X
+1 IF X?5N1"."5N
QUIT
+2 IF X?7N
QUIT
+3 IF X?7N1"."1.6N
QUIT
+4 SET X=-1
+5 KILL X1
+6 QUIT
+7 ;
EDITX1 ; EDIT X1
+1 IF X?5N1"."5N
QUIT
+2 IF X?7N
QUIT
+3 IF X?7N1"."1.6N
QUIT
+4 SET X=-1
+5 KILL X1
+6 QUIT
+7 ;