source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XUWORKDY.m@ 724

Last change on this file since 724 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 1.4 KB
Line 
1XUWORKDY ;SF/GJL - WORKDAYS Mon-Fri ;09/04/98 13:29
2 ;;8.0;KERNEL;**65,71,77,91**;Jul 10, 1995
3 ;X,X1 are any two dates (YYYMMDD). X=Working Days Between
4A N %A,%B,%D,%H,%I,%J,%K,%M,%Y,%Z
5 S %A=X,%B=X1,%Z=1 I %A>%B S X=%B,%B=%A,%A=X,%Z=-1
6 S %J=$$HDTC(%A) I %J<0 S X="" G EXIT ;Imprecise date
7 S %K=$$HDTC(%B) I %K<0 S X="" G EXIT
8 S %H=0,X=(%J+3#7>4)&(%K+3#7>4) ;I $O(^HOLIDAY(2000000))'>0 S X="" G EXIT
9 S %Y=%A-1 F %I=1:1 S %Y=$O(^HOLIDAY(%Y)) Q:(%Y'>0)!(%Y>%B) S %H=%H+1
10 F %J=%J:1 S %Y=%J#7 Q:((%Y=3)!(%J=%K)) S:%Y-2 X=X+1
11 F %K=%K:-1 S %Y=%K#7 Q:((%Y=3)!(%K=%J)) S:%Y-2 X=X+1
12 S %I=%K-%J I '%I S %Y=%J#7 S:(%Y'=2)&(%Y'=3) X=X+1
13 S X=(X+%I-%H-(%I\7*2))*%Z S:X X=X-%Z
14EXIT K X1
15 Q
16HDTC(X) ;Taken from H^%DTC
17 S %M=$E(X,4,5),%D=$E(X,6,7) I '%M!'%D S %Y=-1 Q -1
18 N %H S %H=$$FMTH^XLFDT(X)
19 S %Y=%H+4#7
20 Q %H
21EN(X,X1) ;Function entry point
22 D A Q X
23 ;
24WORKDAY(X) ;This function will determine if the input date is a workday.
25 ;InPut: Fileman date.
26 ;OutPut: 1 is a workday, 0 not a workday
27 I $D(^HOLIDAY(X)) Q 0
28 S X=$$DOW^XLFDT(X) I (X["Saturday")!(X["Sunday") Q 0
29 Q 1
30WORKPLUS(XUDAY,XUOFF) ;Find the date N working day +/- of date D1
31 N %X,%Y,%Z,%D ;%D direction, %X abs days, %Y Workdays, %Z temp
32 I XUOFF=0 Q XUDAY ;Return starting date
33 S %Y=0
34 S XUOFF=+$P(XUOFF,"."),%D=$S(XUOFF<0:-1,1:1),%X=(XUOFF\7*2)+XUOFF
35 F D Q:XUOFF=%Y
36 . S %Z=$$FMADD^XLFDT(XUDAY,%X)
37 . S %Y=$$EN(XUDAY,%Z)
38 . I XUOFF'=%Y S %X=%X+%D
39 . Q
40 Q %Z
Note: See TracBrowser for help on using the repository browser.