ASUAUTL1 ;DSD/DFM - DATE UTILITY FUNCTIONS; [ 04/15/98 2:56 PM ]
;;3.0;SAMS;**1**;AUG 20, 1993
DAYTIM ;EP; - SET DATE AND TIME
D DATE
D TIME
I $D(ASUTRNS) S ASUTRNS(ASUTRNS,"DATE ENTERED")=ASUK("DATE","FM")_"."_ASUK("TIME","F")_"."_$J
Q
DATE ;EP; - SET ASUK("DATE")
N X
I ($D(ASUK("DATE"))#10)=0 D
.D NOW^%DTC S Y=% X ^DD("DD")
.D SETDT
Q
SETDT ;
S DT=X,DN=X
S ASUK("DATE","FM")=X,ASUK("DATE")=$P(Y,"@",1),ASUK("DATE","TIME")=Y
S ASUK("DATE","ENXYR")=$E(X,1,3)+1_"1231"
S ASUK("DATE","YEAR")=$P(ASUK("DATE"),",",2),ASUK("DATE","YMD")=$E(X,2,7)
S ASUK("DATE","YR")=$E(X,2,3),ASUK("DATE","MO")=$E(X,4,5),ASUK("DATE","DA")=$E(X,6,7)
S ASUK("DATE","CFYEDT")=$E(X,1,3)
S ASUK("DATE","MONTH")=$P(ASUK("DATE")," ")
S ASUK("DATE","YRMO")=$E(X,2,5)
S ASUK("DATE","FYMO")=ASUK("DATE","YRMO")
S ASUK("DATE","CFY")=ASUK("DATE","YR")
I +ASUK("DATE","MO")>9 D
.S ASUK("DATE","CFYEDT")=ASUK("DATE","CFYEDT")+1
.S ASUK("DATE","CFY")=$E(ASUK("DATE","CFYEDT"),2,3)
.S ASUK("DATE","FYMO")=ASUK("DATE","CFY")_ASUK("DATE","MO")
S ASUK("DATE","PFYBDT")=ASUK("DATE","CFYEDT")-1
S ASUK("DATE","PFY")=$E(ASUK("DATE","PFYBDT"),2,3)
S ASUK("DATE","CFYEDT")=ASUK("DATE","CFYEDT")_"1231"
S ASUK("DATE","PFYBDT")=ASUK("DATE","PFYBDT")_"0131"
Q:'$D(%H)
S ASUK("DATE","H")=$P(%H,",",1),ASUK("TIME","H")=$P(%H,",",2)
S ASUK("TIME")=$P(Y,"@",2)
Q
ASKDATE ;EP - ASK FOR A DATE AND SET ASUK("DATE") ARRAY
S %DT="AS" D ^%DT S X=Y
X ^DD("DD")
D SETDT,TIME
Q
TIME ;EP; - SET ASUK("TIME")
N X
S %H=$H D YX^%DTC
S ASUK("TIME")=$P(Y,"@",2),ASUK("TIME","H")=$P(%H,",",2)
S ASUK("TIME","F")=$P(ASUK("TIME"),":")_$P(ASUK("TIME"),":",2)_$P(ASUK("TIME"),":",3)
I ($D(ASUK("DATE"))#10) D
.S ASUK("DATE","TIME")=ASUK("DATE")_"@"_ASUK("TIME")
E D
.S ASUK("DATE","TIME")=Y
Q
GETRUN ;EP ; - GET RUN FISCAL YEAR AND MONTH
I ($D(ASUK("DATE"))#10)'=1 D DATE
S DIR(0)="D" D ^DIR K DIR
Q:$D(DTOUT) Q:$D(DUOUT)
S ASUK("DATE","RUNMY")=$E(Y,4,5)_$E(Y,2,3)
W !
S ASUK("DATE","RUNMO")=$E(ASUK("DATE","RUNMY"),1,2)
S ASUK("DATE","RUNYR")=$E(ASUK("DATE","RUNMY"),3,4)
I $E(ASUK("DATE","RUNMO"),1)=0&($E(ASUK("DATE","RUNMO"),2,2))>0 D
.S ASUK("DATE","RUNMO")=$E(ASUK("DATE","RUNMO"),2,2)
Q
SETQTR ;PEP ;SET QUARTER - INPUT DT AND ASUK("DATE","RUNMO") OUTPUT ASUK("DATE","RUNQTR") IN YEARQT FORMAT
I ($D(ASUK("DATE"))#10)'=1 D DATE
I '$D(ASUK("DATE","RUNMO")) S DIR("A")="Enter Month & Fiscal Year for Quarterly Reports (MMFY)" D GETRUN
Q:$D(DTOUT) Q:$D(DUOUT)
S ASUVYR=$S(ASUK("DATE","RUNYR")<60:20,1:19)_ASUK("DATE","RUNYR")
S ASUK("DATE","RUNQTR")=ASUVYR_$S(ASUK("DATE","RUNMO")<4:"02",ASUK("DATE","RUNMO")<7:"03",ASUK("DATE","RUNMO")>9:"01",1:"04")
K ASUVYR
Q
ASUAUTL1 ;DSD/DFM - DATE UTILITY FUNCTIONS; [ 04/15/98 2:56 PM ]
+1 ;;3.0;SAMS;**1**;AUG 20, 1993
DAYTIM ;EP; - SET DATE AND TIME
+1 DO DATE
+2 DO TIME
+3 IF $DATA(ASUTRNS)
SET ASUTRNS(ASUTRNS,"DATE ENTERED")=ASUK("DATE","FM")_"."_ASUK("TIME","F")_"."_$JOB
+4 QUIT
DATE ;EP; - SET ASUK("DATE")
+1 NEW X
+2 IF ($DATA(ASUK("DATE"))#10)=0
Begin DoDot:1
+3 DO NOW^%DTC
SET Y=%
XECUTE ^DD("DD")
+4 DO SETDT
End DoDot:1
+5 QUIT
SETDT ;
+1 SET DT=X
SET DN=X
+2 SET ASUK("DATE","FM")=X
SET ASUK("DATE")=$PIECE(Y,"@",1)
SET ASUK("DATE","TIME")=Y
+3 SET ASUK("DATE","ENXYR")=$EXTRACT(X,1,3)+1_"1231"
+4 SET ASUK("DATE","YEAR")=$PIECE(ASUK("DATE"),",",2)
SET ASUK("DATE","YMD")=$EXTRACT(X,2,7)
+5 SET ASUK("DATE","YR")=$EXTRACT(X,2,3)
SET ASUK("DATE","MO")=$EXTRACT(X,4,5)
SET ASUK("DATE","DA")=$EXTRACT(X,6,7)
+6 SET ASUK("DATE","CFYEDT")=$EXTRACT(X,1,3)
+7 SET ASUK("DATE","MONTH")=$PIECE(ASUK("DATE")," ")
+8 SET ASUK("DATE","YRMO")=$EXTRACT(X,2,5)
+9 SET ASUK("DATE","FYMO")=ASUK("DATE","YRMO")
+10 SET ASUK("DATE","CFY")=ASUK("DATE","YR")
+11 IF +ASUK("DATE","MO")>9
Begin DoDot:1
+12 SET ASUK("DATE","CFYEDT")=ASUK("DATE","CFYEDT")+1
+13 SET ASUK("DATE","CFY")=$EXTRACT(ASUK("DATE","CFYEDT"),2,3)
+14 SET ASUK("DATE","FYMO")=ASUK("DATE","CFY")_ASUK("DATE","MO")
End DoDot:1
+15 SET ASUK("DATE","PFYBDT")=ASUK("DATE","CFYEDT")-1
+16 SET ASUK("DATE","PFY")=$EXTRACT(ASUK("DATE","PFYBDT"),2,3)
+17 SET ASUK("DATE","CFYEDT")=ASUK("DATE","CFYEDT")_"1231"
+18 SET ASUK("DATE","PFYBDT")=ASUK("DATE","PFYBDT")_"0131"
+19 IF '$DATA(%H)
QUIT
+20 SET ASUK("DATE","H")=$PIECE(%H,",",1)
SET ASUK("TIME","H")=$PIECE(%H,",",2)
+21 SET ASUK("TIME")=$PIECE(Y,"@",2)
+22 QUIT
ASKDATE ;EP - ASK FOR A DATE AND SET ASUK("DATE") ARRAY
+1 SET %DT="AS"
DO ^%DT
SET X=Y
+2 XECUTE ^DD("DD")
+3 DO SETDT
DO TIME
+4 QUIT
TIME ;EP; - SET ASUK("TIME")
+1 NEW X
+2 SET %H=$HOROLOG
DO YX^%DTC
+3 SET ASUK("TIME")=$PIECE(Y,"@",2)
SET ASUK("TIME","H")=$PIECE(%H,",",2)
+4 SET ASUK("TIME","F")=$PIECE(ASUK("TIME"),":")_$PIECE(ASUK("TIME"),":",2)_$PIECE(ASUK("TIME"),":",3)
+5 IF ($DATA(ASUK("DATE"))#10)
Begin DoDot:1
+6 SET ASUK("DATE","TIME")=ASUK("DATE")_"@"_ASUK("TIME")
End DoDot:1
+7 IF '$TEST
Begin DoDot:1
+8 SET ASUK("DATE","TIME")=Y
End DoDot:1
+9 QUIT
GETRUN ;EP ; - GET RUN FISCAL YEAR AND MONTH
+1 IF ($DATA(ASUK("DATE"))#10)'=1
DO DATE
+2 SET DIR(0)="D"
DO ^DIR
KILL DIR
+3 IF $DATA(DTOUT)
QUIT
IF $DATA(DUOUT)
QUIT
+4 SET ASUK("DATE","RUNMY")=$EXTRACT(Y,4,5)_$EXTRACT(Y,2,3)
+5 WRITE !
+6 SET ASUK("DATE","RUNMO")=$EXTRACT(ASUK("DATE","RUNMY"),1,2)
+7 SET ASUK("DATE","RUNYR")=$EXTRACT(ASUK("DATE","RUNMY"),3,4)
+8 IF $EXTRACT(ASUK("DATE","RUNMO"),1)=0&($EXTRACT(ASUK("DATE","RUNMO"),2,2))>0
Begin DoDot:1
+9 SET ASUK("DATE","RUNMO")=$EXTRACT(ASUK("DATE","RUNMO"),2,2)
End DoDot:1
+10 QUIT
SETQTR ;PEP ;SET QUARTER - INPUT DT AND ASUK("DATE","RUNMO") OUTPUT ASUK("DATE","RUNQTR") IN YEARQT FORMAT
+1 IF ($DATA(ASUK("DATE"))#10)'=1
DO DATE
+2 IF '$DATA(ASUK("DATE","RUNMO"))
SET DIR("A")="Enter Month & Fiscal Year for Quarterly Reports (MMFY)"
DO GETRUN
+3 IF $DATA(DTOUT)
QUIT
IF $DATA(DUOUT)
QUIT
+4 SET ASUVYR=$SELECT(ASUK("DATE","RUNYR")<60:20,1:19)_ASUK("DATE","RUNYR")
+5 SET ASUK("DATE","RUNQTR")=ASUVYR_$SELECT(ASUK("DATE","RUNMO")<4:"02",ASUK("DATE","RUNMO")<7:"03",ASUK("DATE","RUNMO")>9:"01",1:"04")
+6 KILL ASUVYR
+7 QUIT