Everyone,
I wanted to post this code for anyone who might find it useful.
The following code is based on Daylight Savings rules for the East Coast USA. Call the function by passing a Smart Date format to it and it returns a Y or N to indicate whether or not the date is in Daylight Savings Time of the year.
-***************************************
-* The following function is used to
-* determine whether or not a certain
-* date is during day light savings time
-* or not.
-* RETURN FORMAT: A1 (Y or N)
-***************************************
DEFINE FUNCTION DSTIMEYN (CURNT_DT/YYMD)
CURNT_YR/YY=CURNT_DT;
CURNT_MT/M =CURNT_DT;
CURNT_DOW/W=CURNT_DT;
CURNT_DOM/D=CURNT_DT;
CURNT_I_DOW/I1=CURNT_DOW;
CURNT_I_DOM/I2=CURNT_DOM;
-***************************************
MTH_ID/A4 =
IF (CURNT_YR LE '2006') THEN
DECODE CURNT_MT( 4 '0604' 10 '0610' ELSE '????') ELSE
DECODE CURNT_MT( 3 '0703' 11 '0711' ELSE '????');
-***************************************
-* The following are used for 2006 and prior.
-***************************************
APR_ID/A1 =
IF (CURNT_I_DOM GE 8) THEN 'Y' ELSE
IF (CURNT_I_DOW EQ 7) THEN 'Y' ELSE
IF (CURNT_I_DOW EQ CURNT_I_DOM) THEN 'N' ELSE
IF (CURNT_I_DOW GT CURNT_I_DOM) THEN 'N' ELSE 'Y';
OCT_ID/A1 =
IF (CURNT_I_DOM LE 24) THEN 'Y' ELSE
IF (CURNT_I_DOW EQ 7) THEN 'N' ELSE
IF (CURNT_I_DOW EQ (CURNT_I_DOM - 24)) THEN 'Y' ELSE
IF (CURNT_I_DOW GT (CURNT_I_DOM - 24)) THEN 'Y' ELSE 'N';
-***************************************
-* The following are used for 2007 and beyond.
-***************************************
MAR_ID/A1 =
IF (CURNT_I_DOM LE 7) THEN 'N' ELSE
IF (CURNT_I_DOM GE 15) THEN 'Y' ELSE
IF (CURNT_I_DOW EQ 7) THEN 'Y' ELSE
IF (CURNT_I_DOW EQ (CURNT_I_DOM - 7)) THEN 'N' ELSE
IF (CURNT_I_DOW GT (CURNT_I_DOM - 7)) THEN 'N' ELSE 'Y';
NOV_ID/A1 =
IF (CURNT_I_DOM GE 8) THEN 'N' ELSE
IF (CURNT_I_DOW EQ 7) THEN 'N' ELSE
IF (CURNT_I_DOW EQ CURNT_I_DOM) THEN 'Y' ELSE
IF (CURNT_I_DOW GT CURNT_I_DOM) THEN 'Y' ELSE 'N';
-***************************************
DSTIMEYN/A1=
IF (CURNT_YR LE '2006') AND (MTH_ID EQ '????') THEN
DECODE CURNT_MT(1 N 2 N 3 N 4 ? 5 Y 6 Y 7 Y 8 Y 9 Y 10 ? 11 N 12 N) ELSE
IF (CURNT_YR GT '2006') AND (MTH_ID EQ '????') THEN
DECODE CURNT_MT(1 N 2 N 3 ? 4 Y 5 Y 6 Y 7 Y 8 Y 9 Y 10 Y 11 ? 12 N) ELSE
IF (MTH_ID EQ '0604') THEN APR_ID ELSE
IF (MTH_ID EQ '0610') THEN OCT_ID ELSE
IF (MTH_ID EQ '0703') THEN MAR_ID ELSE
IF (MTH_ID EQ '0711') THEN NOV_ID ELSE '@';
END
Thanks!
Mickey
| FOCUS/WebFOCUS 1990 - 2011 |