./ ADD NAME=PARMTZ      01 00 98319 99319 160857 0158 0158 0000 IBMUSER
//IBMUSERA JOB T,PARMTZ,CLASS=A,NOTIFY=JJ,MSGCLASS=A                    00010000
//ASMA90   EXEC PGM=ASMA90,PARM='DECK,NOOBJ'                            00020000
//SYSPRINT DD  SYSOUT=*                                                 00030000
//SYSLIB   DD  DSN=SYS1.MACLIB,DISP=SHR                                 00040000
//         DD  DSN=SYS1.MODGEN,DISP=SHR                                 00050000
//SYSUT1   DD  UNIT=SYSALLDA,SPACE=(CYL,10)                             00060000
//SYSPUNCH DD  DSN=&&PUNCH,DISP=(NEW,PASS),UNIT=SYSALLDA,SPACE=(CYL,10) 00070000
 TITLE 'Retrieve active GMT offset'                                     00080000
*********************************************************************** 00090000
*                                                                     * 00100000
* Justification:                                                      * 00110000
*   The TZ variable needs to be adjusted on a regular basis for       * 00120000
*   daylight saving.  under normal (non oe) circumstances this        * 00130000
*   is either done in SYS1.PARMLIB(CLOCKxx), or on a SYSPLEX timer.   * 00140000
*   This function will remove the need to update TZ separately        * 00150000
*   from CLOCKxx or the SYSPLEX timer                                 * 00160000
*                                                                     * 00170000
* Function:                                                           * 00180000
*   Retrieve the local date/time offset and present this in a manner  * 00190000
*   compatible with the TZ variable specifications.                   * 00200000
*                                                                     * 00210000
* Example:                                                            * 00220000
*   export TZ=CET`/usr/local/bin/parmtz`         (/etc/profile)       * 00230000
*                                                                     * 00240000
* Logic:                                                              * 00250000
*   Obtain workarea                                                   * 00260000
*   Retrieve offset from CVT in STCK format                           * 00270000
*   Convert to character format                                       * 00280000
*   Write resule to STDOUT                                            * 00290000
*   Release workarea                                                  * 00300000
*   Return to caller                                                  * 00310000
*                                                                     * 00320000
* Register usage                                                      * 00330000
*   R0     Not used                                                   * 00340000
*   R1-R2  Work                                                       * 00350000
*   R3     CVT                                                        * 00360000
*   R4     CVT extension                                              * 00370000
*   R5-R11 Not used                                                   * 00380000
*   R12    EPA and program base                                       * 00390000
*   R13    Save area and work area                                    * 00400000
*   R14    Return address                                             * 00410000
*   R15    Return code                                                * 00420000
*                                                                     * 00430000
* Attributes:                                                         * 00440000
*   AMODE(31),RMODE(ANY)                                              * 00450000
*                                                                     * 00460000
* History:                                                            * 00470000
*   Date       By              Comments                               * 00480000
*   15/11/98   Jan Jaeger      Initial version                        * 00490000
*                                                                     * 00500000
*********************************************************************** 00510000
PARMTZ   RSECT ,                                                        00520000
PARMTZ   AMODE 31                                                       00530000
PARMTZ   RMODE ANY                                                      00540000
         BAKR  R14,0                                                    00550000
         BASR  R12,0                                                    00560000
         USING *,R12                                                    00570000
*                                                                       00580000
         STORAGE OBTAIN,               Obtain work and savearea        X00590000
               LENGTH=WALEN                                             00600000
         LR    R13,R1                                                   00610000
         MVC   4(4,R1),=C'F1SA'                                         00620000
         USING WORKAREA,R13                                             00630000
*                                                                       00640000
         L     R3,CVTPTR               Address CVT                      00650000
         USING CVT,R3                                                   00660000
         L     R4,CVTEXT2              and the extension that contains  00670000
         USING CVTXTNT2,R4               the timezone offset            00680000
*                                                                       00690000
         MVC   OUTPUT,FORMAT           Initialise output field          00700000
         MVC   OFFSETS,CVTLDTO                                          00710000
         TM    CVTLDTO,X'80'           Are we EAST or WEST              00720000
         BNO   ISPOS                                                    00730000
         MVI   SIGN,C'+'               GMT is ahead of us (We are EAST) 00740000
         XC    OFFSETS,=8X'FF'         One's complement is good enough  00750000
ISPOS    DS    0H                                                       00760000
*                                                                       00770000
         LM    R0,R1,OFFSETS           Add half a second to nullify     00780000
         AL    R1,HALFSEC                rounding errors                00790000
         BC    B'1100',NOOVF                                            00800000
         AL    R0,=F'1'                                                 00810000
         ST    R0,OFFSETS                                               00820000
NOOVF    DS    0H                                                       00830000
         ST    R1,OFFSETS+4                                             00840000
*                                                                       00850000
         STCKCONV STCKVAL=OFFSETS,     Convert STCK to HHMMSS          X00860000
               CONVVAL=OFFSETP,                                        X00870000
               TIMETYPE=DEC                                             00880000
         MVI   OFFSETO+3,X'0F'         Convert                          00890000
         MVO   OFFSETO,OFFSETP(3)        packed                         00900000
         UNPK  OFFSETC,OFFSETO             to                           00910000
         OI    OFFSETC+5,C'0'                character                  00920000
         MVC   HH,OFFSETC              Move                             00930000
         MVC   MM,OFFSETC+2              into                           00940000
         MVC   SS,OFFSETC+4                output field                 00950000
*                                                                       00960000
         LA    R1,OUTPUT               Address of output field          00970000
         ST    R1,OUTAREA              Store for all to WRT             00980000
         CALL  BPX1WRT,                                                X00990000
               (=A(STDOUT_FILENO),     File descriptor of STDOUT       X01000000
               OUTAREA,                Buffer address                  X01010000
               =A(0),                  Buffer alet                     X01020000
               =A(L'OUTPUT),           Buffer length                   X01030000
               RET,                    Bytes written or -1             X01040000
               RC,                     Return code                     X01050000
               RS),                    Reason code                     X01060000
               VL,MF=(E,LCALL)                                          01070000
*                                                                       01080000
         L     R2,RC                   Save return code from BPX1WRT    01090000
         LR    R1,R13                                                   01100000
         STORAGE RELEASE,                                              X01110000
               LENGTH=WALEN,                                           X01120000
               ADDR=(1)                                                 01130000
*                                                                       01140000
         LR    R15,R2                  Pass return code back to caller  01150000
         PR    ,                                                        01160000
*                                                                       01170000
HALFSEC  DC    XL4'7A120000'           Half a second                    01180000
*                                                                       01190000
FORMAT   DC    X'604B4B7A4B4B7A4B4B15' +HH:MM:SS<NL>                    01200000
*                                                                       01210000
         LTORG ,                                                        01220000
*                                                                       01230000
WORKAREA DSECT                                                          01240000
SAVEAREA DS    18F                                                      01250000
OFFSETS  DS    1D             STCK format                               01260000
OFFSETP  DS    XL16           X'HHMMSSthmiju0YYYYDDD'                   01270000
OFFSETO  DS    XL4            X'0HHMMSSF'                               01280000
OFFSETC  DS    CL6            C'HHMMSS'                                 01290000
LCALL    DS    7F             CALL BPX1WRT(....)                        01300000
OUTAREA  DS    A              A(OUTPUT)                                 01310000
OUTPUT   DS    CL(L'FORMAT)                                             01320000
SIGN     EQU   OUTPUT,1,C'C'                                            01330000
HH       EQU   OUTPUT+1,2,C'C'                                          01340000
MM       EQU   OUTPUT+4,2,C'C'                                          01350000
SS       EQU   OUTPUT+7,2,C'C'                                          01360000
NL       EQU   OUTPUT+9,1,C'C'                                          01370000
RET      DS    F                                                        01380000
RC       DS    F                                                        01390000
RS       DS    F                                                        01400000
WALEN    EQU   *-WORKAREA                                               01410000
*                                                                       01420000
         CVT   DSECT=YES                                                01430000
*                                                                       01440000
         BPXYCONS ,                                                     01450000
         YREGS ,                                                        01460000
*                                                                       01470000
         END   ,                                                        01480000
//IEWL     EXEC PGM=HEWL,                                               01490000
//          PARM='AMODE=31,RMODE=ANY,CASE=MIXED,STORENX,MAP,XREF'       01500000
//SYSPRINT DD  SYSOUT=*                                                 01510000
//SYSUT1   DD  UNIT=SYSALLDA,SPACE=(CYL,10)                             01520000
//SYSLMOD  DD  PATH='/usr/local/bin'                                    01530000
//SYSLIB   DD  DSN=SYS1.CSSLIB,DISP=SHR                                 01540000
//SYSLIN   DD  DSN=&&PUNCH,DISP=(OLD,DELETE)                            01550000
//         DD  *                                                        01560000
 SETOPT PARM(PATHMODE(0,7,5,5))                                         01570000
 NAME ./parmtz                                                          01580000
