Return to the CL Tips
Automate Daylight Savings time change
/************************************************************/ /* CAll program and it will starts every year the 1. Jan. */ /* The program creates 3 jobs in Job Scheduler. */ /* */ /* 1. Beginning of Daylight Savings. (STRDAYLSAV) */ /* 2. End of Daylight Savings. (ENDDAYLSAV) */ /* 3. Start this job for Daylight Savings next year */ /* (DAYLSAV) */ /* */ /* If you start the job after Daylight Saving is ended */ /* this year, it only add the DAYLSAV job in the JOB */ /* Scheduler. If you start it in the Daylight Savings */ /* Periode, it will add the end of Daylight Savings. */ /* */ /* This program uses QUSRTOOLS: RTVDAT - ADDDAT */ /************************************************************/ PGM DCL VAR(&DATFMT) TYPE(*CHAR) LEN(3) DCL VAR(&YEAR) TYPE(*CHAR) LEN(2) DCL VAR(&DAY3U) TYPE(*CHAR) LEN(3) DCL VAR(&NEWYEAR) TYPE(*CHAR) LEN(6) DCL VAR(&STRD) TYPE(*CHAR) LEN(6) DCL VAR(&STRDV) TYPE(*DEC) LEN(6) DCL VAR(&ENDD) TYPE(*CHAR) LEN(6) DCL VAR(&ENDDV) TYPE(*DEC) LEN(6) /* Check System Date Format */ RTVSYSVAL SYSVAL(QDATFMT) RTNVAR(&DATFMT) IF COND(&DATFMT *NE 'DMY') THEN(GOTO END_PGM) /* Initialse Variables */ RTVSYSVAL SYSVAL(QYEAR) RTNVAR(&YEAR) CHGVAR VAR(&STRD) VALUE('3103' *CAT &YEAR) CHGVAR VAR(&ENDD) VALUE('3110' *CAT &YEAR) CHGVAR VAR(&STRDV) VALUE(&STRD) CHGVAR VAR(&ENDDV) VALUE(&ENDD) /* Find Last Sunday in Martz */ SUNMAR: CHGVAR VAR(&STRD) VALUE(&STRDV) RTVDAT DATE(&STRD) DAY3U(&DAY3U) IF COND(&DAY3U *NE 'SUN') THEN(DO) CHGVAR VAR(&STRDV) VALUE(&STRDV - 10000) GOTO SUNMAR ENDDO /* Add job to JOB Scheduler with last sunday in Martz */ CHGVAR VAR(&STRD) VALUE(&STRDV) ADDJOBSCDE JOB(STRDAYLSAV) CMD(CHGSYSVAL SYSVAL(QHOUR) + VALUE('03')) FRQ(*ONCE) SCDDATE(&STRD) + SCDTIME(020000) TEXT('Beginning of + Daylight Saving') MONMSG MSGID(CPF0000) /* Find Last Sunday in October */ SUNOCT: CHGVAR VAR(&ENDD) VALUE(&ENDDV) RTVDAT DATE(&ENDD) DAY3U(&DAY3U) IF COND(&DAY3U *NE 'SUN') THEN(DO) CHGVAR VAR(&ENDDV) VALUE(&ENDDV - 10000) GOTO SUNOCT ENDDO /* Add job to JOB Scheduler with last Sunday in October */ ADDJOBSCDE JOB(ENDDAYLSAV) CMD(CHGSYSVAL SYSVAL(QHOUR) + VALUE('02')) FRQ(*ONCE) SCDDATE(&ENDD) + SCDTIME(030000) TEXT('End of Daylight + Saving') MONMSG MSGID(CPF0000) /* Add job DAYLSAV to JOB Scheduler with 1/1 next year */ ADDDAT DAYS(365) TOVAR(&NEWYEAR) DATE(*TODAY) CHGVAR VAR(&NEWYEAR) VALUE('0101' *CAT + %SST(&NEWYEAR 5 2)) ADDJOBSCDE JOB(DAYLSAV) CMD(CALL PGM(DAYLSAV)) + FRQ(*ONCE) SCDDATE(&NEWYEAR) SCDTIME(120000) MONMSG MSGID(CPF0000) END_PGM: ENDPGM
[report a broken link by clicking here]