source: ccr/trunk/p/CCRUTIL.m@ 116

Last change on this file since 116 was 116, checked in by George Lilly, 16 years ago

another fix to date format. this time where minute or second are one digit

File size: 2.3 KB
Line 
1CCRUTIL ;CCRCCD/SMH - Various Utilites for generating the CCR/CCD;06/15/08
2 ;;0.1;CCRCCD;;Jun 15, 2008;
3 ;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 W "No Entry at Top!" Q
21
22FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic
23 ; FORMAT is Format of Date. Can be either D (Day) or DT (Date and Time)
24 ; If not passed, or passed incorrectly, it's assumed that it is D.
25 ; FM Date format is "YYYMMDD.HHMMSS" HHMMSS may not be supplied.
26 ; UTC date is formatted as follows: YYYY-MM-DDThh:mm:ss_offsetfromUTC
27 ; UTC, Year, Month, Day, Hours, Minutes, Seconds, Time offset (obtained from Mailman Site Parameters)
28 N UTC,Y,M,D,H,MM,S,OFF
29 S Y=1700+$E(DATE,1,3)
30 S M=$E(DATE,4,5)
31 S D=$E(DATE,6,7)
32 S H=$E(DATE,9,10)
33 S MM=$E(DATE,11,12)
34 I $L(MM)=1 S MM="0"_MM
35 S S=$E(DATE,13,14)
36 I $L(S)=1 S S="0"_S
37 S OFF=$$TZ^XLFDT ; See Kernel Manual for documentation.
38 ; If H, MM and S are empty, it means that the FM date didn't supply the time.
39 ; In this case, set H, MM and S to "00"
40 ; S:('$L(H)&'$L(MM)&'$L(S)) (H,MM,S)="00" ; IF ONLY SOME ARE MISSING?
41 S:'$L(H) H="00"
42 S:'$L(MM) MM="00"
43 S:'$L(S) S="00"
44 S UTC=Y_"-"_M_"-"_D_"T"_H_":"_MM_$S(S="":":00",1:":"_S)_OFF ; Skip's code to fix hanging colon if no seconds
45 I $L($G(FORMAT)),FORMAT="DT" Q UTC ; Date with time.
46 E Q $P(UTC,"T")
47 ;
Note: See TracBrowser for help on using the repository browser.