[comp.lang.asm370] Time conversion

bytheway@cs.utah.edu (Sidney Bytheway) (04/09/91)

In article <9104091932.AA01859@ucbvax.Berkeley.EDU> IBM 370 Assembly Programming Discussion List <ASM370@OHSTVMA.BITNET> writes:
>Does anyone know how to convert the SNNTTIME field in dsect
>DFHSNNT to a HHMMSS format that is easily usable for display
>purposes?  I think its in STCK format?
>
>
>                            Paul Myers (zprm@aacc)
>                            Anne Arundel Community College
>                            301-541-2414

The following is a routine we use at the University of Utah to convert
STCK time to a more managable format.  From here you can use CVD and UNPK
to get it into printable form.

-------- example use of dptodcnv ---------
*
MMDDYY	DS	0CL6
MONTH	DS	CL2
DAY	DS	CL2
YEAR	DS	CL2
PWORK	DS	D
SYSDATE	DS	D
STORCLK	DS	0CL32
CLKYY	DS	F
CLKMM	DS	F
CLKDD	DS	F
	DS	5F
*
	STCK	SYSDATE
	LINK	EP=DPTODCNV,PARAM=(SYSDATE,STORCLK),VL=1
	L	R3,CLKMM
	CVD	R3,PWORK
	UNPK	MONTH,PWORK
	OI	MONTH+1,X'F0'
*
-------- example use of dptodcnv ---------


DPTODCNV TITLE 'DPTODCNV - CONVERT TOD CLOCK VALUE'
*
* DPTODCNV - CONVERT TOD CLOCK VALUE.  THIS PROGRAM IS CALLED USING
*            STANDART LINKAGE CONVENTIONS TO CONVERT AN 8-BYTE TIME OF
*            DAY CLOCK VALUE TO YEAR, MONTH, DAY, HOUR, MINUTE, AND
*            MICROSECONDS.
*
*            ON ENTRY, REGISTER 1 HAS THE ADDRESS OF A PARAMETER LIST.
*            THE FIRST WORD OF THE PARAMETER LIST IS THE ADDRESS OF THE
*            8-BYTE TIME OF DAY CLOCK VALUE; THE SECOND WORD HAS THE
*            ADDRESS OF THE 8-WORD RETURN AREA.  THIS PROGRAM WILL SET
*            THE RETURN AREA TO THE VALUES:
*
*              4-BYTE BINARY YEAR (0 = THE YEAR 1900)
*              4-BYTE BINARY MONTH (1 TO 12)
*              4-BYTE BINARY DAY OF MONTH (1 TO 31)
*              4-BYTE BINARY HOUR OF DAY (00 TO 23)
*              4-BYTE BINARY MINUTE OF HOUR (00 TO 59)
*              4-BYTE BINARY MICROSECOND OF MINUTE (00 TO 59999999)
*              4-BYTE BINARY DAY OF WEEK (0 TO 6; 0=SUNDAY)
*              4-BYTE BINARY DAY OF YEAR (1 TO 366)
*
*            ON RETURN, THIS PROGRAM SETS REGISTER 15 TO 0 (TO AVOID
*            SOME PROBLEMS WITH THE COBOL RETURN-CODE REGISTER).
*
*   BY M. QUINLAN - UNIVERSITY OF UTAH
*   
*
         EJECT
DPTODCNV PGMSTART SA=SA,PGMBASE=REG12,PARMREG=REG11
         EJECT
*
* CNVRTTOD - CONVERT THE TOD VALUE.
*
*            THIS CODE IS DERIVED FROM THE "TODEBCD" ROUTINE IN THE
*            DFHXMOLS PROGRAM DISTRIBUTED WITH CICS RELEASE 1.5.
*
CNVRTTOD EQU   *
         L     REG14,0(REG11)      GET ADDRESS OF TOD VALUE
         SPACE 1
* CONVERT TOD VALUE TO DAYS SINCE DAY 0, HOURS IN DAY, MINUTES IN HOUR,
* AND MICROSECONDS IN MINUTE.  DAY 0 IS JAN 1, 1900.
         LM    REG0,REG1,0(REG14)  GET TOD VALUE
         SRDL  REG0,12             CONVERT VALUE TO MICROSECONDS
         D     REG0,=F'60000000'   DIVIDE BY # MICROSEC IN 1 MINUTE
         LR    REG10,REG0          R10=ODD MICROSEC LESS THAN A MINUTE
         SLR   REG0,REG0           CLEAR FOR DIVIDE
         D     REG0,=F'60'         DIVIDE MINUTES BY 60 TO GET HOURS
         LR    REG9,REG0           R9=ODD MINUTES LESS THAN 1 HOUR
         SLR   REG0,REG0           CLEAR FOR DIVIDE
         D     REG0,=F'24'         DIV HRS BY 24 TO GET DYS & ODD HRS
         LR    REG8,REG0           R8=ODD HOURS LESS THAN 1 DAY
         SPACE 1
* REG1 HAS THE NUMBER OF DAYS SINCE DAY 0.
         SPACE 1
* COMPUTE THE DAY OF THE WEEK
         LA    REG3,1(,REG1)       R3=DAY COUNT SINCE SUNDAY LONG PAST
         SLR   REG2,REG2           CLEAR FOR DIVIDE
         D     REG2,=F'7'          R2=DAY OF WEEK (0=SUNDAY -> 6=SAT.)
         ST    REG2,DAYOFWK#       SAVE DAY OF WEEK
         SPACE 1
* NOW COMPUTE THE YEAR NUMBER; REG1 HAS NUMBER OF DAYS SINCE DAY 0.
         SLR   REG7,REG7           ASSUME NOT A LEAP YEAR FOR NOW
         S     REG1,=F'365'        SUBTRACT # OF DAYS IN YR 1900
         BNM   CVTOD010            BRANCH IF YEAR NOT = 1900
* TREAT THE YEAR 1900 AS A SPECIAL CASE
         LA    REG2,365(,REG1)     SET DAY OF YEAR (RELATIVE TO 0)
         SLR   REG5,REG5           SET YEAR = 1900
         B     CVTOD030            GO CALC DAY OF YEAR
* NOT THE YEAR 1900
CVTOD010 EQU   *                   NOT THE YEAR 1900
         SLR   REG0,REG0           CLEAR FOR DIVIDE
         D     REG0,=F'1461'       DIV DYS BY DYS IN 4 YRS ((4*365)+1)
         SLL   REG1,2              MULT BY 4 TO GET YEAR NUMBER
         LA    REG5,1(,REG1)       R5=YRS LESS ODD YRS SINCE 1900
         LR    REG3,REG0           R3=REMAINING DAYS IN 4-YR PERIOD
         SLR   REG2,REG2           CLEAR FOR DIVIDE
         D     REG2,=F'365'        GET # ODD YRS AND # ODD DAYS
         CL    REG3,=F'3'          CHECK FOR LEAP YEAR
         BL    CVTOD020            BRANCH IF NOT A LEAP YEAR
         LA    REG7,1              ADJUST EXTRA DAY REGISTER FOR LEAPYR
         BE    CVTOD020            BRANCH IF NOT LAST DAY OF LEAP YEAR
         BCTR  REG3,0              DECR YEAR TO FORCE IT = 3
         LA    REG2,365            SET FOR LAST DAY OF YR (REL. TO 0)
CVTOD020 EQU   *
         ALR   REG5,REG3           R5 HAS YEARS SINCE 1900
         EJECT
CVTOD030 EQU   *
* R2=DAY OF YEAR (RELATIVE TO ZERO); R7=1 IF LEAP YEAR, 0 OTHERWISE
* COMPUTE THE MONTH AND DAY OF MONTH.  THIS CODE USES SOME MAGIC
* NUMBERS TO FIGURE OUT WHAT THE MONTH AND DAY OF MONTH ARE; IT IS
* COPIES FROM THE DFHXMOLS PROGRAM.
         LA    REG2,1(,REG2)       MAKE DAY OF YR RELATIVE TO 1
         ST    REG2,DAYOFYR        SAVE THE DAY OF THE YEAR
         LA    REG1,59(,REG7)      R1=60 IF LEAPYR; 59 OTHERWISE
         CLR   REG2,REG1           IS THE DATE PAST FEBRUARY?
         BNH   CVTOD040            NO: LET DATE STAND AS IS
         LA    REG2,2(,REG2)       SET FOR NON-LEAPYEAR INITIALLY
         SLR   REG2,REG7           SUBTRACT 1 IF A LEAP YEAR
CVTOD040 EQU   *
         LA    REG3,91(,REG2)      R3=DAY OF YEAR + 91
         LR    REG7,REG3           COPY FOR LATER
         M     REG2,=F'2145'       MAGIC NUMBER
         SRL   REG3,16             DIV BY 65536 TO GET MONTH NUMBER+2
         LR    REG6,REG3           R6=MONTH NUMBER + 2
         S     REG6,=F'2'          R6=MONTH NUMBER
         M     REG2,=F'1955'       ANOTHER MAGIC NUMBER
         SRL   REG3,6              DIV BY 64 GET TOT DYS IN PAST MON+91
         SLR   REG7,REG3           R7 = DAY OF MONTH
         EJECT
*
* REG5     = YEAR NUMBER            (0 = 1900)
* REG6     = MONTH NUMBER           (1 TO 12)
* REG7     = DAY OF MONTH           (1 TO 31)
* REG8     = HOUR OF DAY            (0 TO 23)
* REG9     = MINUTE OF HOUR         (0 TO 59)
* REG10    = MICROSECONDS OF MINUTE (0 TO 59999999)
* DAYOFWK# = DAY OF WEEK            (0 TO 6; 0=SUNDAY)
* DAYOFYR  = DAY OF YEAR            (1 TO 366)
*
         SPACE 1
* RETURN THE TIME VALUES TO THE CALLER
         L     REG1,4(,REG11)      GET RETURN AREA ADDRESS
         STM   REG5,REG10,0(REG1)  SET RETURN AREA VALUES
         MVC   24(4,REG1),DAYOFWK# RETURN DAY OF WEEK VALUE
         MVC   28(4,REG1),DAYOFYR  RETURN DAY OF YEAR VALUE
         SPACE 1
* RETURN TO THE CALLER
         L     REG13,4(,REG13)     RESTORE OLD SAVE AREA
         RETURN (14,12),RC=0       RETURN TO THE CALLER
         EJECT
*
* DATA AREAS
*
         LTORG
SA       DC    9D'0'
DAYOFWK# DC    F'-1'
DAYOFYR  DC    F'-1'
         END

ZPRM@AACC.BITNET (ZPRM000) (04/10/91)

Does anyone know how to convert the SNNTTIME field in dsect
DFHSNNT to a HHMMSS format that is easily usable for display
purposes?  I think its in STCK format?


                            Paul Myers (zprm@aacc)
                            Anne Arundel Community College
                            301-541-2414

bytheway@CS.UTAH.EDU (Sidney Bytheway) (04/10/91)

In article <9104091932.AA01859@ucbvax.Berkeley.EDU> IBM 370 Assembly
        Programming Discussion List <ASM370@OHSTVMA.BITNET> writes:
>Does anyone know how to convert the SNNTTIME field in dsect
>DFHSNNT to a HHMMSS format that is easily usable for display
>purposes?  I think its in STCK format?
>
>
>                            Paul Myers (zprm@aacc)
>                            Anne Arundel Community College
>                            301-541-2414

The following is a routine we use at the University of Utah to convert
STCK time to a more managable format.  From here you can use CVD and UNPK
to get it into printable form.

-------- example use of dptodcnv ---------
*
MMDDYY  DS      0CL6
MONTH   DS      CL2
DAY     DS      CL2
YEAR    DS      CL2
PWORK   DS      D
SYSDATE DS      D
STORCLK DS      0CL32
CLKYY   DS      F
CLKMM   DS      F
CLKDD   DS      F
        DS      5F
*
        STCK    SYSDATE
        LINK    EP=DPTODCNV,PARAM=(SYSDATE,STORCLK),VL=1
        L       R3,CLKMM
        CVD     R3,PWORK
        UNPK    MONTH,PWORK
        OI      MONTH+1,X'F0'
*
-------- example use of dptodcnv ---------


DPTODCNV TITLE 'DPTODCNV - CONVERT TOD CLOCK VALUE'
*
* DPTODCNV - CONVERT TOD CLOCK VALUE.  THIS PROGRAM IS CALLED USING
*            STANDART LINKAGE CONVENTIONS TO CONVERT AN 8-BYTE TIME OF
*            DAY CLOCK VALUE TO YEAR, MONTH, DAY, HOUR, MINUTE, AND
*            MICROSECONDS.
*
*            ON ENTRY, REGISTER 1 HAS THE ADDRESS OF A PARAMETER LIST.
*            THE FIRST WORD OF THE PARAMETER LIST IS THE ADDRESS OF THE
*            8-BYTE TIME OF DAY CLOCK VALUE; THE SECOND WORD HAS THE
*            ADDRESS OF THE 8-WORD RETURN AREA.  THIS PROGRAM WILL SET
*            THE RETURN AREA TO THE VALUES:
*
*              4-BYTE BINARY YEAR (0 = THE YEAR 1900)
*              4-BYTE BINARY MONTH (1 TO 12)
*              4-BYTE BINARY DAY OF MONTH (1 TO 31)
*              4-BYTE BINARY HOUR OF DAY (00 TO 23)
*              4-BYTE BINARY MINUTE OF HOUR (00 TO 59)
*              4-BYTE BINARY MICROSECOND OF MINUTE (00 TO 59999999)
*              4-BYTE BINARY DAY OF WEEK (0 TO 6; 0=SUNDAY)
*              4-BYTE BINARY DAY OF YEAR (1 TO 366)
*
*            ON RETURN, THIS PROGRAM SETS REGISTER 15 TO 0 (TO AVOID
*            SOME PROBLEMS WITH THE COBOL RETURN-CODE REGISTER).
*
*   BY M. QUINLAN - UNIVERSITY OF UTAH
*
*
         EJECT
DPTODCNV PGMSTART SA=SA,PGMBASE=REG12,PARMREG=REG11
         EJECT
*
* CNVRTTOD - CONVERT THE TOD VALUE.
*
*            THIS CODE IS DERIVED FROM THE "TODEBCD" ROUTINE IN THE
*            DFHXMOLS PROGRAM DISTRIBUTED WITH CICS RELEASE 1.5.
*
CNVRTTOD EQU   *
         L     REG14,0(REG11)      GET ADDRESS OF TOD VALUE
         SPACE 1
* CONVERT TOD VALUE TO DAYS SINCE DAY 0, HOURS IN DAY, MINUTES IN HOUR,
* AND MICROSECONDS IN MINUTE.  DAY 0 IS JAN 1, 1900.
         LM    REG0,REG1,0(REG14)  GET TOD VALUE
         SRDL  REG0,12             CONVERT VALUE TO MICROSECONDS
         D     REG0,=F'60000000'   DIVIDE BY # MICROSEC IN 1 MINUTE
         LR    REG10,REG0          R10=ODD MICROSEC LESS THAN A MINUTE
         SLR   REG0,REG0           CLEAR FOR DIVIDE
         D     REG0,=F'60'         DIVIDE MINUTES BY 60 TO GET HOURS
         LR    REG9,REG0           R9=ODD MINUTES LESS THAN 1 HOUR
         SLR   REG0,REG0           CLEAR FOR DIVIDE
         D     REG0,=F'24'         DIV HRS BY 24 TO GET DYS & ODD HRS
         LR    REG8,REG0           R8=ODD HOURS LESS THAN 1 DAY
         SPACE 1
* REG1 HAS THE NUMBER OF DAYS SINCE DAY 0.
         SPACE 1
* COMPUTE THE DAY OF THE WEEK
         LA    REG3,1(,REG1)       R3=DAY COUNT SINCE SUNDAY LONG PAST
         SLR   REG2,REG2           CLEAR FOR DIVIDE
         D     REG2,=F'7'          R2=DAY OF WEEK (0=SUNDAY -> 6=SAT.)
         ST    REG2,DAYOFWK#       SAVE DAY OF WEEK
         SPACE 1
* NOW COMPUTE THE YEAR NUMBER; REG1 HAS NUMBER OF DAYS SINCE DAY 0.
         SLR   REG7,REG7           ASSUME NOT A LEAP YEAR FOR NOW
         S     REG1,=F'365'        SUBTRACT # OF DAYS IN YR 1900
         BNM   CVTOD010            BRANCH IF YEAR NOT = 1900
* TREAT THE YEAR 1900 AS A SPECIAL CASE
         LA    REG2,365(,REG1)     SET DAY OF YEAR (RELATIVE TO 0)
         SLR   REG5,REG5           SET YEAR = 1900
         B     CVTOD030            GO CALC DAY OF YEAR
* NOT THE YEAR 1900
CVTOD010 EQU   *                   NOT THE YEAR 1900
         SLR   REG0,REG0           CLEAR FOR DIVIDE
         D     REG0,=F'1461'       DIV DYS BY DYS IN 4 YRS ((4*365)+1)
         SLL   REG1,2              MULT BY 4 TO GET YEAR NUMBER
         LA    REG5,1(,REG1)       R5=YRS LESS ODD YRS SINCE 1900
         LR    REG3,REG0           R3=REMAINING DAYS IN 4-YR PERIOD
         SLR   REG2,REG2           CLEAR FOR DIVIDE
         D     REG2,=F'365'        GET # ODD YRS AND # ODD DAYS
         CL    REG3,=F'3'          CHECK FOR LEAP YEAR
         BL    CVTOD020            BRANCH IF NOT A LEAP YEAR
         LA    REG7,1              ADJUST EXTRA DAY REGISTER FOR LEAPYR
         BE    CVTOD020            BRANCH IF NOT LAST DAY OF LEAP YEAR
         BCTR  REG3,0              DECR YEAR TO FORCE IT = 3
         LA    REG2,365            SET FOR LAST DAY OF YR (REL. TO 0)
CVTOD020 EQU   *
         ALR   REG5,REG3           R5 HAS YEARS SINCE 1900
         EJECT
CVTOD030 EQU   *
* R2=DAY OF YEAR (RELATIVE TO ZERO); R7=1 IF LEAP YEAR, 0 OTHERWISE
* COMPUTE THE MONTH AND DAY OF MONTH.  THIS CODE USES SOME MAGIC
* NUMBERS TO FIGURE OUT WHAT THE MONTH AND DAY OF MONTH ARE; IT IS
* COPIES FROM THE DFHXMOLS PROGRAM.
         LA    REG2,1(,REG2)       MAKE DAY OF YR RELATIVE TO 1
         ST    REG2,DAYOFYR        SAVE THE DAY OF THE YEAR
         LA    REG1,59(,REG7)      R1=60 IF LEAPYR; 59 OTHERWISE
         CLR   REG2,REG1           IS THE DATE PAST FEBRUARY?
         BNH   CVTOD040            NO: LET DATE STAND AS IS
         LA    REG2,2(,REG2)       SET FOR NON-LEAPYEAR INITIALLY
         SLR   REG2,REG7           SUBTRACT 1 IF A LEAP YEAR
CVTOD040 EQU   *
         LA    REG3,91(,REG2)      R3=DAY OF YEAR + 91
         LR    REG7,REG3           COPY FOR LATER
         M     REG2,=F'2145'       MAGIC NUMBER
         SRL   REG3,16             DIV BY 65536 TO GET MONTH NUMBER+2
         LR    REG6,REG3           R6=MONTH NUMBER + 2
         S     REG6,=F'2'          R6=MONTH NUMBER
         M     REG2,=F'1955'       ANOTHER MAGIC NUMBER
         SRL   REG3,6              DIV BY 64 GET TOT DYS IN PAST MON+91
         SLR   REG7,REG3           R7 = DAY OF MONTH
         EJECT
*
* REG5     = YEAR NUMBER            (0 = 1900)
* REG6     = MONTH NUMBER           (1 TO 12)
* REG7     = DAY OF MONTH           (1 TO 31)
* REG8     = HOUR OF DAY            (0 TO 23)
* REG9     = MINUTE OF HOUR         (0 TO 59)
* REG10    = MICROSECONDS OF MINUTE (0 TO 59999999)
* DAYOFWK# = DAY OF WEEK            (0 TO 6; 0=SUNDAY)
* DAYOFYR  = DAY OF YEAR            (1 TO 366)
*
         SPACE 1
* RETURN THE TIME VALUES TO THE CALLER
         L     REG1,4(,REG11)      GET RETURN AREA ADDRESS
         STM   REG5,REG10,0(REG1)  SET RETURN AREA VALUES
         MVC   24(4,REG1),DAYOFWK# RETURN DAY OF WEEK VALUE
         MVC   28(4,REG1),DAYOFYR  RETURN DAY OF YEAR VALUE
         SPACE 1
* RETURN TO THE CALLER
         L     REG13,4(,REG13)     RESTORE OLD SAVE AREA
         RETURN (14,12),RC=0       RETURN TO THE CALLER
         EJECT
*
* DATA AREAS
*
         LTORG
SA       DC    9D'0'
DAYOFWK# DC    F'-1'
DAYOFYR  DC    F'-1'
         END

DBA004@UKCC.UKY.EDU ("Massey, Mike") (04/10/91)

On Tue, 9 Apr 91 15:18:47 EST ZPRM000 said:
>Does anyone know how to convert the SNNTTIME field in dsect
>DFHSNNT to a HHMMSS format that is easily usable for display
>purposes?  I think its in STCK format?
>
>
>                            Paul Myers (zprm@aacc)
>                            Anne Arundel Community College
>                            301-541-2414
I have a routine that converts the system clock value to a timestamp...
YYYY-MM-DD-HH.MM.SS.SSSSSS
If I can find it, I will post it.

FERZAN@TREARN.BITNET (OHAN) (04/10/91)

          I have a time program, it gets the timer value from TOD CLOCK,
          and displays following line:

CLOCK xx:xx:xx:xxx:xxx xx, DATE xx/xx/xxxx xxxxxxxxx, ZONE xx:xx:xx/xxxx

      |  |  |  |   |   |        |  |  |    |               |  |  |  |
      |  |  |  |   |   |        |  |  |    |               |  |  |  |
hour --  |  |  |   |   |        |  |  |    |               |  |  |  |
minute ---  |  |   |   |        |  |  |    |               |  |  |  |
second ------  |   |   |        |  |  |    |               |  |  |  |
millisecond ----   |   |        |  |  |    |               |  |  |  |
microsecond --------   |        |  |  |    |               |  |  |  |
am/pm ------------------        |  |  |    |               |  |  |  |
month ---------------------------  |  |    |               |  |  |  |
day of month -----------------------  |    |               |  |  |  |
year ----------------------------------    |               |  |  |  |
day of week --------------------------------               |  |  |  |
hour -------------------------------------------------------  |  |  |
minute --------------------------------------------------------  |  |
second -----------------------------------------------------------  |
west/gmt/east -------------------------------------------------------

(time zone is difference between local time and Greenwich Mean Time)
/**/

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (04/11/91)

ZPRM@AACC.BITNET (ZPRM000) writes:

>Does anyone know how to convert the SNNTTIME field in dsect
>DFHSNNT to a HHMMSS format that is easily usable for display
>purposes?  I think its in STCK format?

I have some code I do this with.  I am posting relevant samples here
which are good enough to copy and adapt to stuff.  But if you want to
assemble what I post, you need more of my macros.  You can get them by
requesting them from me by E-mail to phil-howard@uiuc.edu (give a BITNET
address if you have one) or by Anonymous FTP to host vmd.cso.uiuc.edu
(128.174.5.98) and cd to "phil.194".

The first program is a REXX function that gives the clock data in a format
a REXX program can play with easily.  The second program is the macro that
I use to generate code to convert the clock.

:READ RXDATIM ASSEMBLE A
RXDATIM  TITLE 'REXX function to convert TOD value to info'             00001000
*********************************************************************** 00002000
* Copyright:  (C) 1990, Philip David Howard - All rights reserved.    * 00003000
*             Permission is granted to the public to distribute this  * 00004000
*             program unaltered provided that no profit is derived    * 00005000
*             from the distribution and that this permission is not   * 00006000
*             denied to others receiving this program.                * 00007000
*                                                                     * 00008000
* Program:    RXDATIM ASSEMBLE                                        * 00009000
*                                                                     * 00010000
* Function:   datim                                                   * 00011000
*                                                                     * 00012000
* Purpose:    To convert a TOD value in decimal such as that from     * 00013000
*             the tod() function into individual date and time        * 00014000
*             information.                                            * 00015000
*                                                                     * 00016000
* Usage:      info = datim( todvalue )                                * 00017000
*                                                                     * 00018000
*             todvalue - The TOD clock value in decimal.  Value will  * 00019000
*                        be from 0 to 2**63-1.                        * 00020000
*                                                                     * 00021000
*             info     - Date and time information separated by       * 00022000
*                        blanks as follows:                           * 00023000
*                                                                     * 00024000
*                        year         - 1900 to 2042                  * 00025000
*                        month        - 1 to 12                       * 00026000
*                        date         - 1 to 31                       * 00027000
*                        day          - 1 to 7                        * 00028000
*                        hour         - 0 to 23                       * 00029000
*                        minute       - 0 to 59                       * 00030000
*                        second       - 0 to 59                       * 00031000
*                        microseconds - 0 to 999999                   * 00032000
*                                                                     * 00033000
* Program:    No time zone adjustments are made.                      * 00034000
*             Those must be made by the calling program.              * 00035000
*                                                                     * 00036000
* Author:     Philip D. Howard                                        * 00037000
* Post:       Computing Services Office                               * 00038000
*             Digital Computer Lab                                    * 00039000
*             University of Illinois at Urbana-Champaign              * 00040000
*             1304 West Springfield Avenue                            * 00041000
*             Urbana, IL  USA-61801                                   * 00042000
* Phone:      217-244-6246                                            * 00043000
* Network:    <PHIL@UIUCVMD.BITNET>                                   * 00044000
*********************************************************************** 00045000
                                                                 EJECT  00046000
*********************************************************************** 00047000
* General declarations.                                               * 00048000
*********************************************************************** 00049000
         INTREL DATIM,DECINT,INUDEC                                     00050000
RXDATIM  NUCEXT ACODE=GODATIM,ZCODE=ENDATIM,(RXDATIM,GODATIM)           00051000
         USING GODATIM,R12                                              00052000
                                                                 SPACE  00053000
*********************************************************************** 00054000
* Begin main entry point.                                             * 00055000
*********************************************************************** 00056000
GODATIM  STM   R14,R12,SAVER14(R13) preserve registers                  00057000
                                                                 SPACE  00058000
         CLM   R1,B'1000',F5+3     is this a REXX call?                 00059000
         BC    NOT-EQUAL,EXIT4     no --> too bad                       00060000
         LTR   R3,R0               is it a function (not call)?         00061000
         BC    NEG,EXIT4           no --> signal error                  00062000
                                                                 SPACE  00063000
         ICM   R11,B'1111',20(R3)  get evalblok return word address     00064000
         BC    ZERO,EXIT4          zero --> signal error                00065000
                                                                 SPACE  00066000
*********************************************************************** 00067000
* Allocate savearea and evalblok.                                     * 00068000
*********************************************************************** 00069000
         LA    R0,9                size to allocate                     00070000
         DMSFREE DWORDS=(0)        get a work area                      00071000
         ST    R13,SAVEPREV(R1)    link...                              00072000
         ST    R1,SAVENEXT(R13)    ...saveareas                         00073000
         LR    R13,R1              use new save area                    00074000
                                                                 SPACE  00075000
         LA    R9,7                size of EVALBLOK / workarea          00076000
         LR    R0,R9               request size                         00077000
         DMSFREE DWORDS=(0)        get an EVALBLOK / workarea           00078000
         ST    R1,0(,R11)          pass EVALBLOK address to REXX now    00079000
         LR    R11,R1              use in this register                 00080000
         XC    0(8*7,R11),0(R11)   clean it up                          00081000
         ST    R9,4(,R11)          put allocated size in header         00082000
                                                                 SPACE  00083000
*********************************************************************** 00084000
* Convert number to internal binary form then to individual numbers.  * 00085000
*********************************************************************** 00086000
         $IF   NOT-ZERO            if                                   00087000
           ICM   R10,B'1111',16(R3)  arg list is present                00088000
         $AND  NOT-EQUAL           and                                  00089000
           CLI   0(R10),X'FF'        arg list has at least one arg      00090000
         $AND  NOT-ZERO            and                                  00091000
           ICM   R2,B'1111',0(R10)   address is not null                00092000
         $AND  NOT-ZERO            and                                  00093000
           ICM   R3,B'1111',4(R10)   length is not null                 00094000
         $AND  CC0+CC1             and                                  00095000
           DECINT ,                  given number is valid              00096000
         $THEN ,                   then                                 00097000
         $ELSE ,                   else                                 00098000
           STCK  16(R13)             use the current TOD clock          00099000
           LM    R0,R1,16(R13)       as if it were specified            00100000
         $END  ,                                                        00101000
                                                                 SPACE  00102000
         DATIM ,                   >>> convert TOD to various info      00103000
                                                                 SPACE  00104000
         LA    R3,1(,R3)           add one to month                     00105000
         LA    R4,1(,R4)           add one to date                      00106000
         LA    R5,1(,R5)           add one to day                       00107000
         STM   R2,R9,24(R11)       array these numbers                  00108000
                                                                 SPACE  00109000
*********************************************************************** 00110000
* Convert numbers to decimal and build resultant value.               * 00111000
* The binary values will be wiped over by the character values, but   * 00112000
* not until they are no longer needed.  The EVALBLOK overlay is:      * 00113000
*             1   1   2   2   2   3   3   4   4   4   5               * 00114000
* 0   4   8   2   6   0   4   8   2   6   0   4   8   2               * 00115000
* ....SSSSLLLL............YYYYMMMMDDDDWWWWHHHHMMMMSSSSUUUU            * 00116000
* ................1988_12_31_7_23_59_59_999999_...........            * 00117000
*********************************************************************** 00118000
         LA    R2,16(,R11)         where decimal numbers first go       00119000
         SLR   R6,R6               start index at 0                     00120000
         LA    R8,8                8 numbers                            00121000
                                                                 SPACE  00122000
LOOP     SLR   R0,R0               clear upper part of 64 bits          00123000
         L     R1,24(R6,R11)       get number                           00124000
         L     R3,NUMTABLE(R6)     get maximum size                     00125000
         LA    R4,1                get minimum size                     00126000
         INUDEC ,                  >>> convert to decimal               00127000
         ALR   R2,R4               adjust address                       00128000
         MVI   0(R2),X'40'         add on a blank                       00129000
         LA    R2,1(,R2)           adjust again                         00130000
         LA    R6,4(,R6)           increment index                      00131000
         BCT   R8,LOOP             count data items                     00132000
                                                                 SPACE  00133000
         LA    R3,17(,R11)         start of string offset +1            00134000
         SLR   R2,R3               length of string less 1 (chop blank) 00135000
         ST    R2,8(,R11)          put actual length in header          00136000
                                                                 SPACE  00137000
*********************************************************************** 00138000
* Return savearea and exit to caller.                                 * 00139000
*********************************************************************** 00140000
RETURN   LR    R1,R13              remember where the savearea is       00141000
         L     R13,SAVEPREV(,R13)  pop the savearea                     00142000
         LA    R0,9                size of a savearea                   00143000
         DMSFRET DWORDS=(0),LOC=(1) return the savearea                 00144000
         SLR   R15,R15             zero return code                     00145000
                                                                 SPACE  00146000
EXIT     L     R14,SAVER14(,R13)   restore R14                          00147000
         LM    R0,R12,SAVER0(R13)  restore R0..R12                      00148000
         BR    R14                 >>> return                           00149000
                                                                 SPACE  00150000
EXIT4    LA    R15,4               set return code to 4                 00151000
         B     EXIT                --> go do regular exit               00152000
                                                                 SPACE  00153000
                                                                 EJECT  00154000
*********************************************************************** 00155000
* Subroutines.                                                        * 00156000
*********************************************************************** 00157000
         INTORG                                                         00158000
                                                                 EJECT  00159000
*********************************************************************** 00160000
* Constants.                                                          * 00161000
*********************************************************************** 00162000
F5       DC    F'5'                constant 5                           00163000
                                                                 SPACE  00164000
         LTORG                                                          00165000
                                                                 SPACE  00166000
NUMTABLE DS    0D                  number size table                    00167000
YEAR     DC    F'4'                1988                                 00168000
MONTH    DC    F'2'                12                                   00169000
DATE     DC    F'2'                31                                   00170000
DAY      DC    F'1'                7                                    00171000
HOUR     DC    F'2'                23                                   00172000
MIN      DC    F'2'                59                                   00173000
SEC      DC    F'2'                59                                   00174000
USEC     DC    F'6'                999999                               00175000
                                                                 SPACE  00176000
ENDATIM  EQU   *                   end of loaded code                   00177000
                                                                 EJECT  00178000
WORKAREA DSECT                                                          00179000
SAVEAREA DS    9D                  save area                            00180000
WORKEND  DS    0D                  end of work area                     00181000
WORKLEN  EQU   WORKEND-WORKAREA    length of workarea                   00182000
WORKSIZ  EQU   WORKLEN/8           size of workarea                     00183000
                                                                 EJECT  00184000
         $EQU                                                           00185000
         NUCON                                                          00186000
         END   RXDATIM                                                  00187000
:READ DATIM MACRO A
         MACRO                                                          00001000
&LABEL   DATIM &PARM,&TYPE=,&NAME=                                      00002000
.********************************************************************** 00003000
.* Copyright:  (C) 1989, Philip David Howard - All rights reserved.   * 00004000
.*             Permission is granted to the public to distribute this * 00005000
.*             program unaltered provided that no profit is derived   * 00006000
.*             from the distribution and that this permission is not  * 00007000
.*             denied to others receiving this program.               * 00008000
.*                                                                    * 00009000
.* Program:    DATIM MACRO                                            * 00010000
.*                                                                    * 00011000
.* Purpose:    To break down a TOD clock value (64 bit unsigned       * 00012000
.*             integer) into various date and time components.        * 00013000
.*                                                                    * 00014000
.* Author:     Philip David Howard,         Research Programmer       * 00015000
.* Internet:   <phil@vmd.cso.uiuc.edu>,     Bitnet: <phil@uiucvmd>    * 00016000
.* Voicenet:   (USA) 217-244-6246                                     * 00017000
.* Papernet:   Computing Services Office,   Room 131-SW               * 00018000
.*             Digital Computer Lab,        MC-256                    * 00019000
.*             University of Illinois at Urbana-Champaign             * 00020000
.*             1304 West Springfield Avenue                           * 00021000
.*             Urbana, IL  USA-61801                                  * 00022000
.********************************************************************** 00023000
         COPY  $MACVAR                                                  00024000
         LCLC  &NDX,&LAB                                                00025000
&MACLAB  SETC  'DATIM'                                                  00026000
&MACRET  SETA  0                                                        00027000
&NDX     SETC  '&SYSNDX'                                                00028000
&LAB     SETC  ''                                                       00029000
         COPY  $MACFND                                                  00030000
         COPY  $MACODE                                                  00031000
         COPY  $MACORG                                                  00032000
*********************************************************************** 00033000
* Copyright:  (C) 1989, Philip David Howard - All rights reserved.    * 00034000
*             Permission is granted to the public to distribute this  * 00035000
*             program unaltered provided that no profit is derived    * 00036000
*             from the distribution and that this permission is not   * 00037000
*             denied to others receiving this program.                * 00038000
*                                                                     * 00039000
* Program:    DATIM subroutine                                        * 00040000
*                                                                     * 00041000
* Purpose:    To break down a TOD clock value (64 bit unsigned        * 00042000
*             integer) into various date and time components.         * 00043000
*                                                                     * 00044000
* Entry:      R0-1: TOD clock value         (64 bit unsigned integer) * 00045000
*             R13:  Standard savearea                                 * 00046000
*                                                                     * 00047000
* Exit:       R0-1: TOD clock unchanged     (64 bit unsigned integer) * 00048000
*             R2:   Year (1900-2042)        (32 bit unsigned integer) * 00049000
*             R3:   Month (0-11)            (32 bit unsigned integer) * 00050000
*             R4:   Date (0-30)             (32 bit unsigned integer) * 00051000
*             R5:   Day (0-6) (MON=0)       (32 bit unsigned integer) * 00052000
*             R6:   Hour (0-23)             (32 bit unsigned integer) * 00053000
*             R7:   Minute (0-59)           (32 bit unsigned integer) * 00054000
*             R8:   Second (0-59)           (32 bit unsigned integer) * 00055000
*             R9:   Microseconds (0-999999) (32 bit unsigned integer) * 00056000
*                                                                     * 00057000
* Author:     Philip David Howard,         Research Programmer        * 00058000
* Internet:   <phil@vmd.cso.uiuc.edu>,     Bitnet: <phil@uiucvmd>     * 00059000
* Voicenet:   (USA) 217-244-6246                                      * 00060000
* Papernet:   Computing Services Office,   Room 131-SW                * 00061000
*             Digital Computer Lab,        MC-256                     * 00062000
*             University of Illinois at Urbana-Champaign              * 00063000
*             1304 West Springfield Avenue                            * 00064000
*             Urbana, IL  USA-61801                                   * 00065000
*********************************************************************** 00066000
                                                                 EJECT  00067000
&LAB     STM   R0,R1,SAVER0(R13)   preserve TOD registers               00068000
         SRDL  R0,12               divide by 4096 for total usecs       00069000
         D     R0,=F'60000000'     microseconds per minute              00070000
                                                                 SPACE  00071000
         LR    R5,R0               microseconds since minute            00072000
         SLR   R4,R4               clear upper half of 64 bit int       00073000
         D     R4,=F'1000000'      microseconds per second              00074000
         LR    R9,R4               MICROSECOND                          00075000
         LR    R8,R5               SECOND                               00076000
                                                                 SPACE  00077000
         SLR   R0,R0               clear upper half of 64 bit int       00078000
         D     R0,=F'60'           minutes per hour                     00079000
         LR    R7,R0               MINUTE                               00080000
                                                                 SPACE  00081000
         SLR   R0,R0               clear upper half of 64 bit int       00082000
         D     R0,=F'24'           hours per day                        00083000
         LR    R6,R0               HOUR                                 00084000
                                                                 SPACE  00085000
         LR    R3,R1               temp copy of total days              00086000
         SLR   R2,R2               clear upper half of 64 bit int       00087000
         D     R2,=F'7'            days per week                        00088000
         LR    R5,R2               DAY                                  00089000
                                                                 SPACE  00090000
         $IF   HIGH+EQUAL          if                                   00091000
           CL    R1,=F'59'           this is 1 Mar 1900 or later        00092000
         $THEN ,                   then                                 00093000
           AL    R1,=F'1'            adjust dates for no 29 Feb 1900    00094000
         $END                                                           00095000
                                                                 SPACE  00096000
         SLR   R0,R0               clear upper half of 64 bit int       00097000
         D     R0,=F'1461'         days per quadyear                    00098000
         ALR   R1,R1               multiple quadyear by...              00099000
         ALR   R1,R1               ...4 to get year offset              00100000
         AL    R1,=F'1900'         plus epoch for real year of quad     00101000
                                                                 SPACE  00102000
         LA    R3,12*4*2           offset to last month code            00103000
         $WHILE LOW                while                                00104000
           CH    R0,MTAB&NDX.(R3)    this month is a future month       00105000
         $DO   ,                   do                                   00106000
           SL    R3,=F'2'            look at previous month             00107000
         $END  ,                                                        00108000
         SH    R0,MTAB&NDX.(R3)    reduce to just date in month         00109000
         LR    R4,R0               DATE                                 00110000
         SRL   R3,1                divide by 2 gives month in quadyear  00111000
                                                                 SPACE  00112000
         SLR   R2,R2                                                    00113000
         D     R2,=F'12'           months per year                      00114000
         ALR   R1,R3               add year in quadyear for final year  00115000
         LR    R3,R2               MONTH                                00116000
         LR    R2,R1               YEAR                                 00117000
                                                                 SPACE  00118000
         LM    R0,R1,SAVER0(R13)   restore TOD registers                00119000
         B     RTRN&NDX            all done -->                         00120000
                                                                 EJECT  00121000
MTAB&NDX DC    H'0'                Jan 1980                             00122000
         DC    H'31'               Feb 1980 leap month                  00123000
         DC    H'60'               Mar 1980                             00124000
         DC    H'91'               Apr 1980                             00125000
         DC    H'121'              May 1980                             00126000
         DC    H'152'              Jun 1980                             00127000
         DC    H'182'              Jul 1980                             00128000
         DC    H'213'              Aug 1980                             00129000
         DC    H'244'              Sep 1980                             00130000
         DC    H'274'              Oct 1980                             00131000
         DC    H'305'              Nov 1980                             00132000
         DC    H'335'              Dec 1980                             00133000
                                                                 SPACE  00134000
         DC    H'366'              Jan 1981                             00135000
         DC    H'397'              Feb 1981                             00136000
         DC    H'425'              Mar 1981                             00137000
         DC    H'456'              Apr 1981                             00138000
         DC    H'486'              May 1981                             00139000
         DC    H'517'              Jun 1981                             00140000
         DC    H'547'              Jul 1981                             00141000
         DC    H'578'              Aug 1981                             00142000
         DC    H'609'              Sep 1981                             00143000
         DC    H'639'              Oct 1981                             00144000
         DC    H'670'              Nov 1981                             00145000
         DC    H'700'              Dec 1981                             00146000
                                                                 SPACE  00147000
         DC    H'731'              Jan 1982                             00148000
         DC    H'762'              Feb 1982                             00149000
         DC    H'790'              Mar 1982                             00150000
         DC    H'821'              Apr 1982                             00151000
         DC    H'851'              May 1982                             00152000
         DC    H'882'              Jun 1982                             00153000
         DC    H'912'              Jul 1982                             00154000
         DC    H'943'              Aug 1982                             00155000
         DC    H'974'              Sep 1982                             00156000
         DC    H'1004'             Oct 1982                             00157000
         DC    H'1035'             Nov 1982                             00158000
         DC    H'1065'             Dec 1982                             00159000
                                                                 SPACE  00160000
         DC    H'1096'             Jan 1983                             00161000
         DC    H'1127'             Feb 1983                             00162000
         DC    H'1155'             Mar 1983                             00163000
         DC    H'1186'             Apr 1983                             00164000
         DC    H'1216'             May 1983                             00165000
         DC    H'1247'             Jun 1983                             00166000
         DC    H'1277'             Jul 1983                             00167000
         DC    H'1308'             Aug 1983                             00168000
         DC    H'1339'             Sep 1983                             00169000
         DC    H'1369'             Oct 1983                             00170000
         DC    H'1400'             Nov 1983                             00171000
         DC    H'1430'             Dec 1983                             00172000
                                                                 EJECT  00173000
RTRN&NDX DS    0H                                                       00174000
         COPY  $MACRET                                                  00175000
         COPY  $MACALL                                                  00176000
         MEND                                                           00177000
-- 
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu                              \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks                             /
 \***************************************************************************/

phil@UX1.CSO.UIUC.EDU (Phil Howard KA9WGN) (04/11/91)

ZPRM@AACC.BITNET (ZPRM000) writes:

>Does anyone know how to convert the SNNTTIME field in dsect
>DFHSNNT to a HHMMSS format that is easily usable for display
>purposes?  I think its in STCK format?

I have some code I do this with.  I am posting relevant samples here
which are good enough to copy and adapt to stuff.  But if you want to
assemble what I post, you need more of my macros.  You can get them by
requesting them from me by E-mail to phil-howard@uiuc.edu (give a BITNET
address if you have one) or by Anonymous FTP to host vmd.cso.uiuc.edu
(128.174.5.98) and cd to "phil.194".

The first program is a REXX function that gives the clock data in a format
a REXX program can play with easily.  The second program is the macro that
I use to generate code to convert the clock.

:READ RXDATIM ASSEMBLE A
RXDATIM  TITLE 'REXX function to convert TOD value to info'             00001000
*********************************************************************** 00002000
* Copyright:  (C) 1990, Philip David Howard - All rights reserved.    * 00003000
*             Permission is granted to the public to distribute this  * 00004000
*             program unaltered provided that no profit is derived    * 00005000
*             from the distribution and that this permission is not   * 00006000
*             denied to others receiving this program.                * 00007000
*                                                                     * 00008000
* Program:    RXDATIM ASSEMBLE                                        * 00009000
*                                                                     * 00010000
* Function:   datim                                                   * 00011000
*                                                                     * 00012000
* Purpose:    To convert a TOD value in decimal such as that from     * 00013000
*             the tod() function into individual date and time        * 00014000
*             information.                                            * 00015000
*                                                                     * 00016000
* Usage:      info = datim( todvalue )                                * 00017000
*                                                                     * 00018000
*             todvalue - The TOD clock value in decimal.  Value will  * 00019000
*                        be from 0 to 2**63-1.                        * 00020000
*                                                                     * 00021000
*             info     - Date and time information separated by       * 00022000
*                        blanks as follows:                           * 00023000
*                                                                     * 00024000
*                        year         - 1900 to 2042                  * 00025000
*                        month        - 1 to 12                       * 00026000
*                        date         - 1 to 31                       * 00027000
*                        day          - 1 to 7                        * 00028000
*                        hour         - 0 to 23                       * 00029000
*                        minute       - 0 to 59                       * 00030000
*                        second       - 0 to 59                       * 00031000
*                        microseconds - 0 to 999999                   * 00032000
*                                                                     * 00033000
* Program:    No time zone adjustments are made.                      * 00034000
*             Those must be made by the calling program.              * 00035000
*                                                                     * 00036000
* Author:     Philip D. Howard                                        * 00037000
* Post:       Computing Services Office                               * 00038000
*             Digital Computer Lab                                    * 00039000
*             University of Illinois at Urbana-Champaign              * 00040000
*             1304 West Springfield Avenue                            * 00041000
*             Urbana, IL  USA-61801                                   * 00042000
* Phone:      217-244-6246                                            * 00043000
* Network:    <PHIL@UIUCVMD.BITNET>                                   * 00044000
*********************************************************************** 00045000
                                                                 EJECT  00046000
*********************************************************************** 00047000
* General declarations.                                               * 00048000
*********************************************************************** 00049000
         INTREL DATIM,DECINT,INUDEC                                     00050000
RXDATIM  NUCEXT ACODE=GODATIM,ZCODE=ENDATIM,(RXDATIM,GODATIM)           00051000
         USING GODATIM,R12                                              00052000
                                                                 SPACE  00053000
*********************************************************************** 00054000
* Begin main entry point.                                             * 00055000
*********************************************************************** 00056000
GODATIM  STM   R14,R12,SAVER14(R13) preserve registers                  00057000
                                                                 SPACE  00058000
         CLM   R1,B'1000',F5+3     is this a REXX call?                 00059000
         BC    NOT-EQUAL,EXIT4     no --> too bad                       00060000
         LTR   R3,R0               is it a function (not call)?         00061000
         BC    NEG,EXIT4           no --> signal error                  00062000
                                                                 SPACE  00063000
         ICM   R11,B'1111',20(R3)  get evalblok return word address     00064000
         BC    ZERO,EXIT4          zero --> signal error                00065000
                                                                 SPACE  00066000
*********************************************************************** 00067000
* Allocate savearea and evalblok.                                     * 00068000
*********************************************************************** 00069000
         LA    R0,9                size to allocate                     00070000
         DMSFREE DWORDS=(0)        get a work area                      00071000
         ST    R13,SAVEPREV(R1)    link...                              00072000
         ST    R1,SAVENEXT(R13)    ...saveareas                         00073000
         LR    R13,R1              use new save area                    00074000
                                                                 SPACE  00075000
         LA    R9,7                size of EVALBLOK / workarea          00076000
         LR    R0,R9               request size                         00077000
         DMSFREE DWORDS=(0)        get an EVALBLOK / workarea           00078000
         ST    R1,0(,R11)          pass EVALBLOK address to REXX now    00079000
         LR    R11,R1              use in this register                 00080000
         XC    0(8*7,R11),0(R11)   clean it up                          00081000
         ST    R9,4(,R11)          put allocated size in header         00082000
                                                                 SPACE  00083000
*********************************************************************** 00084000
* Convert number to internal binary form then to individual numbers.  * 00085000
*********************************************************************** 00086000
         $IF   NOT-ZERO            if                                   00087000
           ICM   R10,B'1111',16(R3)  arg list is present                00088000
         $AND  NOT-EQUAL           and                                  00089000
           CLI   0(R10),X'FF'        arg list has at least one arg      00090000
         $AND  NOT-ZERO            and                                  00091000
           ICM   R2,B'1111',0(R10)   address is not null                00092000
         $AND  NOT-ZERO            and                                  00093000
           ICM   R3,B'1111',4(R10)   length is not null                 00094000
         $AND  CC0+CC1             and                                  00095000
           DECINT ,                  given number is valid              00096000
         $THEN ,                   then                                 00097000
         $ELSE ,                   else                                 00098000
           STCK  16(R13)             use the current TOD clock          00099000
           LM    R0,R1,16(R13)       as if it were specified            00100000
         $END  ,                                                        00101000
                                                                 SPACE  00102000
         DATIM ,                   >>> convert TOD to various info      00103000
                                                                 SPACE  00104000
         LA    R3,1(,R3)           add one to month                     00105000
         LA    R4,1(,R4)           add one to date                      00106000
         LA    R5,1(,R5)           add one to day                       00107000
         STM   R2,R9,24(R11)       array these numbers                  00108000
                                                                 SPACE  00109000
*********************************************************************** 00110000
* Convert numbers to decimal and build resultant value.               * 00111000
* The binary values will be wiped over by the character values, but   * 00112000
* not until they are no longer needed.  The EVALBLOK overlay is:      * 00113000
*             1   1   2   2   2   3   3   4   4   4   5               * 00114000
* 0   4   8   2   6   0   4   8   2   6   0   4   8   2               * 00115000
* ....SSSSLLLL............YYYYMMMMDDDDWWWWHHHHMMMMSSSSUUUU            * 00116000
* ................1988_12_31_7_23_59_59_999999_...........            * 00117000
*********************************************************************** 00118000
         LA    R2,16(,R11)         where decimal numbers first go       00119000
         SLR   R6,R6               start index at 0                     00120000
         LA    R8,8                8 numbers                            00121000
                                                                 SPACE  00122000
LOOP     SLR   R0,R0               clear upper part of 64 bits          00123000
         L     R1,24(R6,R11)       get number                           00124000
         L     R3,NUMTABLE(R6)     get maximum size                     00125000
         LA    R4,1                get minimum size                     00126000
         INUDEC ,                  >>> convert to decimal               00127000
         ALR   R2,R4               adjust address                       00128000
         MVI   0(R2),X'40'         add on a blank                       00129000
         LA    R2,1(,R2)           adjust again                         00130000
         LA    R6,4(,R6)           increment index                      00131000
         BCT   R8,LOOP             count data items                     00132000
                                                                 SPACE  00133000
         LA    R3,17(,R11)         start of string offset +1            00134000
         SLR   R2,R3               length of string less 1 (chop blank) 00135000
         ST    R2,8(,R11)          put actual length in header          00136000
                                                                 SPACE  00137000
*********************************************************************** 00138000
* Return savearea and exit to caller.                                 * 00139000
*********************************************************************** 00140000
RETURN   LR    R1,R13              remember where the savearea is       00141000
         L     R13,SAVEPREV(,R13)  pop the savearea                     00142000
         LA    R0,9                size of a savearea                   00143000
         DMSFRET DWORDS=(0),LOC=(1) return the savearea                 00144000
         SLR   R15,R15             zero return code                     00145000
                                                                 SPACE  00146000
EXIT     L     R14,SAVER14(,R13)   restore R14                          00147000
         LM    R0,R12,SAVER0(R13)  restore R0..R12                      00148000
         BR    R14                 >>> return                           00149000
                                                                 SPACE  00150000
EXIT4    LA    R15,4               set return code to 4                 00151000
         B     EXIT                --> go do regular exit               00152000
                                                                 SPACE  00153000
                                                                 EJECT  00154000
*********************************************************************** 00155000
* Subroutines.                                                        * 00156000
*********************************************************************** 00157000
         INTORG                                                         00158000
                                                                 EJECT  00159000
*********************************************************************** 00160000
* Constants.                                                          * 00161000
*********************************************************************** 00162000
F5       DC    F'5'                constant 5                           00163000
                                                                 SPACE  00164000
         LTORG                                                          00165000
                                                                 SPACE  00166000
NUMTABLE DS    0D                  number size table                    00167000
YEAR     DC    F'4'                1988                                 00168000
MONTH    DC    F'2'                12                                   00169000
DATE     DC    F'2'                31                                   00170000
DAY      DC    F'1'                7                                    00171000
HOUR     DC    F'2'                23                                   00172000
MIN      DC    F'2'                59                                   00173000
SEC      DC    F'2'                59                                   00174000
USEC     DC    F'6'                999999                               00175000
                                                                 SPACE  00176000
ENDATIM  EQU   *                   end of loaded code                   00177000
                                                                 EJECT  00178000
WORKAREA DSECT                                                          00179000
SAVEAREA DS    9D                  save area                            00180000
WORKEND  DS    0D                  end of work area                     00181000
WORKLEN  EQU   WORKEND-WORKAREA    length of workarea                   00182000
WORKSIZ  EQU   WORKLEN/8           size of workarea                     00183000
                                                                 EJECT  00184000
         $EQU                                                           00185000
         NUCON                                                          00186000
         END   RXDATIM                                                  00187000
:READ DATIM MACRO A
         MACRO                                                          00001000
&LABEL   DATIM &PARM,&TYPE=,&NAME=                                      00002000
.********************************************************************** 0000300
.* Copyright:  (C) 1989, Philip David Howard - All rights reserved.   * 0000400
.*             Permission is granted to the public to distribute this * 0000500
.*             program unaltered provided that no profit is derived   * 0000600
.*             from the distribution and that this permission is not  * 0000700
.*             denied to others receiving this program.               * 0000800
.*                                                                    * 0000900
.* Program:    DATIM MACRO                                            * 0001000
.*                                                                    * 0001100
.* Purpose:    To break down a TOD clock value (64 bit unsigned       * 0001200
.*             integer) into various date and time components.        * 0001300
.*                                                                    * 0001400
.* Author:     Philip David Howard,         Research Programmer       * 0001500
.* Internet:   <phil@vmd.cso.uiuc.edu>,     Bitnet: <phil@uiucvmd>    * 0001600
.* Voicenet:   (USA) 217-244-6246                                     * 0001700
.* Papernet:   Computing Services Office,   Room 131-SW               * 0001800
.*             Digital Computer Lab,        MC-256                    * 0001900
.*             University of Illinois at Urbana-Champaign             * 0002000
.*             1304 West Springfield Avenue                           * 0002100
.*             Urbana, IL  USA-61801                                  * 0002200
.********************************************************************** 0002300
         COPY  $MACVAR                                                  00024000
         LCLC  &NDX,&LAB                                                00025000
&MACLAB  SETC  'DATIM'                                                  00026000
&MACRET  SETA  0                                                        00027000
&NDX     SETC  '&SYSNDX'                                                00028000
&LAB     SETC  ''                                                       00029000
         COPY  $MACFND                                                  00030000
         COPY  $MACODE                                                  00031000
         COPY  $MACORG                                                  00032000
*********************************************************************** 00033000
* Copyright:  (C) 1989, Philip David Howard - All rights reserved.    * 00034000
*             Permission is granted to the public to distribute this  * 00035000
*             program unaltered provided that no profit is derived    * 00036000
*             from the distribution and that this permission is not   * 00037000
*             denied to others receiving this program.                * 00038000
*                                                                     * 00039000
* Program:    DATIM subroutine                                        * 00040000
*                                                                     * 00041000
* Purpose:    To break down a TOD clock value (64 bit unsigned        * 00042000
*             integer) into various date and time components.         * 00043000
*                                                                     * 00044000
* Entry:      R0-1: TOD clock value         (64 bit unsigned integer) * 00045000
*             R13:  Standard savearea                                 * 00046000
*                                                                     * 00047000
* Exit:       R0-1: TOD clock unchanged     (64 bit unsigned integer) * 00048000
*             R2:   Year (1900-2042)        (32 bit unsigned integer) * 00049000
*             R3:   Month (0-11)            (32 bit unsigned integer) * 00050000
*             R4:   Date (0-30)             (32 bit unsigned integer) * 00051000
*             R5:   Day (0-6) (MON=0)       (32 bit unsigned integer) * 00052000
*             R6:   Hour (0-23)             (32 bit unsigned integer) * 00053000
*             R7:   Minute (0-59)           (32 bit unsigned integer) * 00054000
*             R8:   Second (0-59)           (32 bit unsigned integer) * 00055000
*             R9:   Microseconds (0-999999) (32 bit unsigned integer) * 00056000
*                                                                     * 00057000
* Author:     Philip David Howard,         Research Programmer        * 00058000
* Internet:   <phil@vmd.cso.uiuc.edu>,     Bitnet: <phil@uiucvmd>     * 00059000
* Voicenet:   (USA) 217-244-6246                                      * 00060000
* Papernet:   Computing Services Office,   Room 131-SW                * 00061000
*             Digital Computer Lab,        MC-256                     * 00062000
*             University of Illinois at Urbana-Champaign              * 00063000
*             1304 West Springfield Avenue                            * 00064000
*             Urbana, IL  USA-61801                                   * 00065000
*********************************************************************** 00066000
                                                                 EJECT  00067000
&LAB     STM   R0,R1,SAVER0(R13)   preserve TOD registers               00068000
         SRDL  R0,12               divide by 4096 for total usecs       00069000
         D     R0,=F'60000000'     microseconds per minute              00070000
                                                                 SPACE  00071000
         LR    R5,R0               microseconds since minute            00072000
         SLR   R4,R4               clear upper half of 64 bit int       00073000
         D     R4,=F'1000000'      microseconds per second              00074000
         LR    R9,R4               MICROSECOND                          00075000
         LR    R8,R5               SECOND                               00076000
                                                                 SPACE  00077000
         SLR   R0,R0               clear upper half of 64 bit int       00078000
         D     R0,=F'60'           minutes per hour                     00079000
         LR    R7,R0               MINUTE                               00080000
                                                                 SPACE  00081000
         SLR   R0,R0               clear upper half of 64 bit int       00082000
         D     R0,=F'24'           hours per day                        00083000
         LR    R6,R0               HOUR                                 00084000
                                                                 SPACE  00085000
         LR    R3,R1               temp copy of total days              00086000
         SLR   R2,R2               clear upper half of 64 bit int       00087000
         D     R2,=F'7'            days per week                        00088000
         LR    R5,R2               DAY                                  00089000
                                                                 SPACE  00090000
         $IF   HIGH+EQUAL          if                                   00091000
           CL    R1,=F'59'           this is 1 Mar 1900 or later        00092000
         $THEN ,                   then                                 00093000
           AL    R1,=F'1'            adjust dates for no 29 Feb 1900    00094000
         $END                                                           00095000
                                                                 SPACE  00096000
         SLR   R0,R0               clear upper half of 64 bit int       00097000
         D     R0,=F'1461'         days per quadyear                    00098000
         ALR   R1,R1               multiple quadyear by...              00099000
         ALR   R1,R1               ...4 to get year offset              00100000
         AL    R1,=F'1900'         plus epoch for real year of quad     00101000
                                                                 SPACE  00102000
         LA    R3,12*4*2           offset to last month code            00103000
         $WHILE LOW                while                                00104000
           CH    R0,MTAB&NDX.(R3)    this month is a future month       00105000
         $DO   ,                   do                                   00106000
           SL    R3,=F'2'            look at previous month             00107000
         $END  ,                                                        00108000
         SH    R0,MTAB&NDX.(R3)    reduce to just date in month         00109000
         LR    R4,R0               DATE                                 00110000
         SRL   R3,1                divide by 2 gives month in quadyear  00111000
                                                                 SPACE  00112000
         SLR   R2,R2                                                    00113000
         D     R2,=F'12'           months per year                      00114000
         ALR   R1,R3               add year in quadyear for final year  00115000
         LR    R3,R2               MONTH                                00116000
         LR    R2,R1               YEAR                                 00117000
                                                                 SPACE  00118000
         LM    R0,R1,SAVER0(R13)   restore TOD registers                00119000
         B     RTRN&NDX            all done -->                         00120000
                                                                 EJECT  00121000
MTAB&NDX DC    H'0'                Jan 1980                             00122000
         DC    H'31'               Feb 1980 leap month                  00123000
         DC    H'60'               Mar 1980                             00124000
         DC    H'91'               Apr 1980                             00125000
         DC    H'121'              May 1980                             00126000
         DC    H'152'              Jun 1980                             00127000
         DC    H'182'              Jul 1980                             00128000
         DC    H'213'              Aug 1980                             00129000
         DC    H'244'              Sep 1980                             00130000
         DC    H'274'              Oct 1980                             00131000
         DC    H'305'              Nov 1980                             00132000
         DC    H'335'              Dec 1980                             00133000
                                                                 SPACE  00134000
         DC    H'366'              Jan 1981                             00135000
         DC    H'397'              Feb 1981                             00136000
         DC    H'425'              Mar 1981                             00137000
         DC    H'456'              Apr 1981                             00138000
         DC    H'486'              May 1981                             00139000
         DC    H'517'              Jun 1981                             00140000
         DC    H'547'              Jul 1981                             00141000
         DC    H'578'              Aug 1981                             00142000
         DC    H'609'              Sep 1981                             00143000
         DC    H'639'              Oct 1981                             00144000
         DC    H'670'              Nov 1981                             00145000
         DC    H'700'              Dec 1981                             00146000
                                                                 SPACE  00147000
         DC    H'731'              Jan 1982                             00148000
         DC    H'762'              Feb 1982                             00149000
         DC    H'790'              Mar 1982                             00150000
         DC    H'821'              Apr 1982                             00151000
         DC    H'851'              May 1982                             00152000
         DC    H'882'              Jun 1982                             00153000
         DC    H'912'              Jul 1982                             00154000
         DC    H'943'              Aug 1982                             00155000
         DC    H'974'              Sep 1982                             00156000
         DC    H'1004'             Oct 1982                             00157000
         DC    H'1035'             Nov 1982                             00158000
         DC    H'1065'             Dec 1982                             00159000
                                                                 SPACE  00160000
         DC    H'1096'             Jan 1983                             00161000
         DC    H'1127'             Feb 1983                             00162000
         DC    H'1155'             Mar 1983                             00163000
         DC    H'1186'             Apr 1983                             00164000
         DC    H'1216'             May 1983                             00165000
         DC    H'1247'             Jun 1983                             00166000
         DC    H'1277'             Jul 1983                             00167000
         DC    H'1308'             Aug 1983                             00168000
         DC    H'1339'             Sep 1983                             00169000
         DC    H'1369'             Oct 1983                             00170000
         DC    H'1400'             Nov 1983                             00171000
         DC    H'1430'             Dec 1983                             00172000
                                                                 EJECT  00173000
RTRN&NDX DS    0H                                                       00174000
         COPY  $MACRET                                                  00175000
         COPY  $MACALL                                                  00176000
         MEND                                                           00177000
--
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu                              \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks                             /
 \***************************************************************************/

ZPRM%AACC@CUNYVM.CUNY.EDU (ZPRM000) (04/11/91)

We are suprised with all the great info about the TOD conversion.
We are trying one of them now.
We wrote a program that runs under CICS that gives a pageable
screen showing termids, virt addresses, real addresses and user
operator info. We want to show the time the term was last active
but cant seem to find any fields in the CICS that contain this time.
There is a field in the SNT that is supose to be a time stamp
in STCK format but its only 4 bytes. Any ideas?

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (04/12/91)

ZPRM%AACC@CUNYVM.CUNY.EDU (ZPRM000) writes:

>We are suprised with all the great info about the TOD conversion.
>We are trying one of them now.
>We wrote a program that runs under CICS that gives a pageable
>screen showing termids, virt addresses, real addresses and user
>operator info. We want to show the time the term was last active
>but cant seem to find any fields in the CICS that contain this time.
>There is a field in the SNT that is supose to be a time stamp
>in STCK format but its only 4 bytes. Any ideas?

The upper 4 bytes of the STCK timestamp is effectively stepped every
1.048576 seconds.  It would be SIMPLEST to just take the upper 4 bytes
of the STCK timestamp and apply the conversions by filling in the
lower 4 bytes with 0's.

HOWEVER it is POSSIBLE they MIGHT be taking the full STCK and shifting it
to the right by 12 bits then dividing by one million exactly to come up
with an integer that is effectively incremented every 1.000000 seconds.

The reason to do that is that it would appear to SOME people that it is
easy to make date calculations on something that is stepped every 1.000000
seconds instead of something that is stepped every 1.048576 seconds.

It is in fact a slight bit faster to make such conversions, but not worth
doing the extra work to save a timestamp in this form.  My recommendation
is to save timestamps in STCK format or part thereof in binary.  Remember
if you must optimize for speed, optimize that which is executed the most.

But timestamps are not worth optmizing much either way.

Anyway you better check and see what method they are using.  Try assuming
the values are just the upper half of the STCK and see what results you
get.  If the answers are not "really close" then it is probably the other
method.
-- 
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu                              \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks                             /
 \***************************************************************************/

phil@UX1.CSO.UIUC.EDU (Phil Howard KA9WGN) (04/12/91)

ZPRM%AACC@CUNYVM.CUNY.EDU (ZPRM000) writes:

>We are suprised with all the great info about the TOD conversion.
>We are trying one of them now.
>We wrote a program that runs under CICS that gives a pageable
>screen showing termids, virt addresses, real addresses and user
>operator info. We want to show the time the term was last active
>but cant seem to find any fields in the CICS that contain this time.
>There is a field in the SNT that is supose to be a time stamp
>in STCK format but its only 4 bytes. Any ideas?

The upper 4 bytes of the STCK timestamp is effectively stepped every
1.048576 seconds.  It would be SIMPLEST to just take the upper 4 bytes
of the STCK timestamp and apply the conversions by filling in the
lower 4 bytes with 0's.

HOWEVER it is POSSIBLE they MIGHT be taking the full STCK and shifting it
to the right by 12 bits then dividing by one million exactly to come up
with an integer that is effectively incremented every 1.000000 seconds.

The reason to do that is that it would appear to SOME people that it is
easy to make date calculations on something that is stepped every 1.000000
seconds instead of something that is stepped every 1.048576 seconds.

It is in fact a slight bit faster to make such conversions, but not worth
doing the extra work to save a timestamp in this form.  My recommendation
is to save timestamps in STCK format or part thereof in binary.  Remember
if you must optimize for speed, optimize that which is executed the most.

But timestamps are not worth optmizing much either way.

Anyway you better check and see what method they are using.  Try assuming
the values are just the upper half of the STCK and see what results you
get.  If the answers are not "really close" then it is probably the other
method.
--
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu                              \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks                             /
 \***************************************************************************/

FERZAN@TREARN.BITNET (OHAN) (04/15/91)

              GETTIME macro gives 1/300 seconds ..

ZPRM%AACC@CUNYVM.CUNY.EDU (ZPRM000) (04/15/91)

We have one of the time conversions working to the point.
It is about about 1 hr 2 min high of the console clock.
Does that ring a bell with anyone?

FERZAN@TREARN.BITNET (04/25/91)

             it is normal to get this result ..
             you must calculate 52 bits TOD value
             to get correct results,

-OR-