Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XBDT

XBDT.m

Go to the documentation of this file.
  1. XBDT ;IHS/HQW/JDH - date/time utilities ;[ 06/19/1998 11:11 AM ]
  1. ;;3.0;IHS/VA UTILITIES;**6**;JUNE 17, 1998
  1. ;
  1. ;FISCAL
  1. ; usage: S %=$$FISCAL^XBDT(XBDT,XBFYMTH,XBADJ)
  1. ;
  1. ; Input: (all parameters are optional)
  1. ; XBDT Date in either fileman of horlog format. If not defined,
  1. ; default is today.
  1. ; XBFYMT Month beginning fiscal year. The definition of this
  1. ; variable can be assigned in the parameter list. If it
  1. ; is not and Beginning fiscal year month field in the
  1. ; PCC MASTER CONTROL file is valued for the current locaton,
  1. ; its value is used. The default is 10.
  1. ; XBADJ The value of this variable allows the adjustment of the
  1. ; FY value
  1. ;
  1. ; Output: current fiscal year^star date of FY^end date of FY
  1. ;
  1. ;LEAP
  1. ; input: (optional) date in Fileman, yyyy or horlog
  1. ; output: boolean 1=yes 0=no
  1. ; uses algorithm defined for leap year in the RPMS Y2000 Compliance Plan
  1. ;
  1. FISCAL(XBDT,XBFYMTH,XBADJ) ; return current fiscal year
  1. ;
  1. N %,T,T1,T2,XBFY,XBFYBEG,XBFYEND
  1. S XBADJ=$G(XBADJ) ; adjustment variable
  1. S:'$G(XBDT) XBDT=$$NOW^XLFDT
  1. S:XBDT["," XBDT=$$HTFM^XLFDT(XBDT) ; horolog to fileman
  1. S T=$P($G(^APCCCTRL(DUZ(2),0)),U,8) ; beg, FY month for location from PCC MASTER CONTROL file
  1. S:'$G(XBFYMTH) XBFYMTH=$S(T:T,1:10) ; use month entered, as in MSTR file or 10
  1. S XBFYMTH=$E("0",XBFYMTH<10)_XBFYMTH ; if month is less then 10 make it two digits
  1. S T1=XBFYMTH-1<$E(XBDT,4,5) ; boolean. month before or after FY start month
  1. S T2=XBDT\10000-'T1 ; current year in FM 3 digit year format plus 1 or 0 determined by T1 calculation
  1. S XBFY=XBDT\10000+T1 ; fiscal Year in external 4 digit format
  1. S XBFYBEG=T2_XBFYMTH_"01" ; beginning of fiscal year
  1. S %=T2+1_XBFYMTH_"01"
  1. S XBFYEND=$$FMADD^XLFDT(%,-1) ;get the beginning date of the fiscal year
  1. Q XBFY+1700+XBADJ_U_XBFYBEG_U_XBFYEND
  1. ;
  1. ;
  1. ;
  1. LEAP(XBDT) ; is the year a leap year?
  1. ;
  1. S:'$G(XBDT) XBDT=$$NOW^XLFDT
  1. S:XBDT["," XBDT=$$HTFM^XLFDT(XBDT) ; horolog to fileman
  1. S:$L(XBDT)>4 XBDT=XBDT\10000+1700 ; 4 digit date
  1. Q '(XBDT#4)&(XBDT#100)!('(XBDT#100)&'(XBDT#400)) ; leap year algorithm
  1. ;