source: FOIAVistA/trunk/r/NOIS-FSC/FSCTIME.m@ 1800

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

initial load of FOIAVistA 6/30/08 version

File size: 2.0 KB
Line 
1FSCTIME ;SLC/STAFF-NOIS Time Conversion ;1/11/98 18:53
2 ;;1.1;NOIS;;Sep 06, 1998
3TIME(X) ; from dd7103, dd7103.1, dd7103.2, dd7105.2
4 ; format X else kill it
5 N OK,X1
6 I X?1"12".A S X=$S(X="12M":"MID",X="12N":"NOON",1:X)
7 I X?1.A S X=$S(X["MID":2400,X["NOON":1200,1:"")
8 I $E(X,$L(X))="M" S X=$E(X,1,$L(X)-1)
9 S X1=$E(X,$L(X)) I X1?1U,"AP"'[X1 K X Q
10 S X1=$P(X,":",2)
11 I X1'="",X1'?2N1.2U K X Q
12 I X'?4N,$S($L(+X)<3:+X,1:+X\100)>12 K X Q
13 S X=$P(X,":",1)_$P(X,":",2),X1=X
14 I X'?4N S OK=1 D I 'OK K X Q
15 .I X'?1.4N1.2U S OK=0
16 .S:X<13 X=X*100 I X1["A" S:X>1259 OK=0 Q:'OK S X=$S(X=1200:2400,X>1159:X-1200,1:X)
17 .I X1'["A",X<1200,X1["P"!(X<600) S X=X+1200 I X<1300 S OK=0
18 I X>2400!('X&(X'="0000"))!(X#100>59) K X Q
19 S X1=+X I 'X1!(X1=1200)!(X1=2400) S X=$S(X1=1200:"NOON",1:"MID") Q
20 S X1=$S(X1>1259:X1-1200,1:X1),X1=$E("000",0,4-$L(X1))_X1_$S(X=2400:"A",X>1159:"P",1:"A")
21 I "00^15^30^45"'[$E(X1,3,4) K X Q
22 S X=$E(X1,1,2)_":"_$E(X1,3,5)
23 Q
24 ;
25CNV ; Convert Start/Stop to minutes
26 ; X=start_"^"_stop Output: Y=start(min)_"^"_stop(min)
27 S CNX=X,X=$P(CNX,"^",1),Y=0 D MIL S Y=Y\100*60+(Y#100),$P(CNX,"^",1)=Y
28 S X=$P(CNX,"^",2),Y=1 D MIL S Y=Y\100*60+(Y#100)
29 S Y=$P(CNX,"^",1)_"^"_Y K CNX Q
30 ;
31MIL(X) ; $$(AM/PM time) -> military time
32 ; X=time Y: 0=Mid=0,1=Mid=2400 Output: Y=time in 2400
33 N Y
34 I X="NOON" Q "1200"
35 I X="MID" Q "2400"
36 S Y=$P(X,":",1)_$P(X,":",2),Y=+Y
37 I X["A" Q Y
38 I Y<1200 S Y=Y+1200
39 Q Y
40 ;
41CONVERT(TIME,FROMZONE,TOZONE) ; $$(time,from timezone,to timezone) -> time
42 N TOFFSET,FOFFSET,DIFF
43 I '$L(TIME)!('$L(FROMZONE))!('$L(TOZONE)) Q TIME
44 S TOFFSET=$P($G(^FSC("TIMEZONE",+$O(^FSC("TIMEZONE","B",TOZONE,0)),0)),U,2)
45 S FOFFSET=$P($G(^FSC("TIMEZONE",+$O(^FSC("TIMEZONE","B",FROMZONE,0)),0)),U,2)
46 I 'TOFFSET Q TIME
47 I 'FOFFSET Q TIME
48 S DIFF=FOFFSET-TOFFSET
49 S TIME=TIME-(DIFF*100)
50 I $L(TIME)=3 S TIME="0"_TIME
51 Q TIME
52 ;
53HLP ; Time Help
54 W !?5,"Time may be entered as 8A or 8a, 8:00A, 8:15A, 8:15AM or military"
55 W !?5,"time: 0800, 1300; or MID or 12M for midnight; NOON or 12N for noon."
56 W !?5,"Time must be in quarter hours; e.g., 8A or 8:15A or 8:30A or 8:45A.",!
57 Q
Note: See TracBrowser for help on using the repository browser.