AUZTI ;MOVE TO "MGR" AND REMOVE THIS LINE [ 05/05/86 10:56 AM ]
%ZTI ;TIME INPUT
;CFL/OKC
Z S:'$D(%TI(0)) %TI(0)="" I '$D(X) S X=""
A1 I %TI(0)["A" R !!,"TIME: ",%TS S X=%TS
S (Y,%Z)="" G END:X=""
G MIL:X?4N,NOW:("NOW"[X),HELP:X?1"?"."?"
F %I=$L(X):-1:1 I $E(X,%I)?1A,"APap"[$E(X,%I) S %Z=$E(X,%I),X=$E(X,1,%I-1)
I X?3N!(X?3N.AP) S %H=$E(X,1),%M=$E(X,2,3) G A11
S %H=+$P(X,":",1),%M=+$P(X,":",2)
A11 I '(%H?1N!(%H?2N))!(%H<1)!(%H>23) G ERR
I %M,'(%M?2N)!(%M>59) G ERR
G A2:%Z'="",ERR:%TI(0)["X" I %H>6,%H<12 S %Z="A" G A2
S %Z="P"
A2 I %Z["P" S:%H<12 %H=%H+12
I %Z["A",%H=12 S %H=0
B1 S Y=%H*3600+(%M*60) D ECHO
G END
MIL S %H=$E(X,1,2),%M=$E(X,3,4) I %H<23,%M<60 G B1
NOW S %H=$P($H,",",2),%M=%H#3600\60,%H=%H\3600 G B1
ERR I %TI(0)["Q" W *7," ??"
I %TI(0)["A" G A1
END K %H,%M,%Z,%TS,%TI
Q
ECHO S %H=Y\3600,%M=Y#3600\60,%Z=$S(Y>43199:"PM",1:"AM"),%M=$E(%M+100,2,3) S:%H>12 %H=%H-12 I '%H S %H=12
S %E=" ("_%H_":"_%M_" "_%Z_")" I %TI(0)["E" W %E
Q
HELP W !!,"Enter The Time In One Of The Following Formats:",!
W !,?5,"10:00 AM",?25,"10:00A",?50,"10A",?65,"1000"
W !!,?5," 2:30 PM",?25," 2:30P",?50,"230P",?65,"1430"
W !!,"Enter 'NOW' For The Current Time."
W !!,?3,"If 'AM' or 'PM' is Ommitted, The Time Is Assumed To Be"
W !!,?3,"Between 7:00 AM and 6:00 PM (Except For Military Time)."
G A1:%TI(0)["A",END
AUZTI ;MOVE TO "MGR" AND REMOVE THIS LINE [ 05/05/86 10:56 AM ]
%ZTI ;TIME INPUT
+1 ;CFL/OKC
Z IF '$DATA(%TI(0))
SET %TI(0)=""
IF '$DATA(X)
SET X=""
A1 IF %TI(0)["A"
READ !!,"TIME: ",%TS
SET X=%TS
+1 SET (Y,%Z)=""
IF X=""
GOTO END
+2 IF X?4N
GOTO MIL
IF ("NOW"[X)
GOTO NOW
IF X?1"?"."?"
GOTO HELP
+3 FOR %I=$LENGTH(X):-1:1
IF $EXTRACT(X,%I)?1A
IF "APap"[$EXTRACT(X,%I)
SET %Z=$EXTRACT(X,%I)
SET X=$EXTRACT(X,1,%I-1)
+4 IF X?3N!(X?3N.AP)
SET %H=$EXTRACT(X,1)
SET %M=$EXTRACT(X,2,3)
GOTO A11
+5 SET %H=+$PIECE(X,":",1)
SET %M=+$PIECE(X,":",2)
A11 IF '(%H?1N!(%H?2N))!(%H<1)!(%H>23)
GOTO ERR
+1 IF %M
IF '(%M?2N)!(%M>59)
GOTO ERR
+2 IF %Z'=""
GOTO A2
IF %TI(0)["X"
GOTO ERR
IF %H>6
IF %H<12
SET %Z="A"
GOTO A2
+3 SET %Z="P"
A2 IF %Z["P"
IF %H<12
SET %H=%H+12
+1 IF %Z["A"
IF %H=12
SET %H=0
B1 SET Y=%H*3600+(%M*60)
DO ECHO
+1 GOTO END
MIL SET %H=$EXTRACT(X,1,2)
SET %M=$EXTRACT(X,3,4)
IF %H<23
IF %M<60
GOTO B1
NOW SET %H=$PIECE($HOROLOG,",",2)
SET %M=%H#3600\60
SET %H=%H\3600
GOTO B1
ERR IF %TI(0)["Q"
WRITE *7," ??"
+1 IF %TI(0)["A"
GOTO A1
END KILL %H,%M,%Z,%TS,%TI
+1 QUIT
ECHO SET %H=Y\3600
SET %M=Y#3600\60
SET %Z=$SELECT(Y>43199:"PM",1:"AM")
SET %M=$EXTRACT(%M+100,2,3)
IF %H>12
SET %H=%H-12
IF '%H
SET %H=12
+1 SET %E=" ("_%H_":"_%M_" "_%Z_")"
IF %TI(0)["E"
WRITE %E
+2 QUIT
HELP WRITE !!,"Enter The Time In One Of The Following Formats:",!
+1 WRITE !,?5,"10:00 AM",?25,"10:00A",?50,"10A",?65,"1000"
+2 WRITE !!,?5," 2:30 PM",?25," 2:30P",?50,"230P",?65,"1430"
+3 WRITE !!,"Enter 'NOW' For The Current Time."
+4 WRITE !!,?3,"If 'AM' or 'PM' is Ommitted, The Time Is Assumed To Be"
+5 WRITE !!,?3,"Between 7:00 AM and 6:00 PM (Except For Military Time)."
+6 IF %TI(0)["A"
GOTO A1
GOTO END