zOs/REXX.O08/TIMETOD

con = x2c('17F6AC7307C07544')                                           00010002
tod = con2tod(con)                                                      00020000
say 'con' c2x(con) 'tod' c2x(tod) 'tst' tod2tst(tod)                    00030002
ts = '2006-12-24-15.21.03.987689'                                       00040002
tod = tst2tod(ts)                                                       00050002
say ts '-> tst2tod ->' c2x(tod)                                         00060002
t2 = tod2tst(tod)                                                       00070002
say t2 '<- tod2tst <-' c2x(tod)                                         00080002
tod = '17B6EA0B0EADABE5'x                                               00090002
t2 = tod2tst(tod)                                                       00100002
say t2 '<- tod2tst <-' c2x(tod)                                         00110002
to2 = tst2tod(t2)                                                       00120002
say t2 '-> tst2tod ->' c2x(to2)                                         00130002
exit                                                                    00140000
/*--- conversion from tod clock value to timestamp ---------------------00150002
      tod is utc ( = sommerzeit -2h, winterzeit -1h                     00160002
                   und LeapSekunden können auch noch differieren|)      00170002
-------------- BLSUXTOD siehe Z/OS V1R7.0 MVS IPCS CUSTOMIZATION -----*/00180002
tod2Tst: procedure                                                      00190002
    parse arg tod                                                       00200002
    tst = left('', 26, '?')                                             00210002
    address linkpgm "BLSUXTOD tod tst"                                  00220002
         /* returns format   MO/DD/YYYY HH:MM:SS.FFFFFF                 00230002
            but we want      YYYY-Mo-DD-HH.MM.SS.FFFFFF  (db2 tst) */   00240002
    parse var tst mo '/' dd '/' yyyy hh ':' mm ':' ss '.' ffffff        00250002
    return yyyy'-'mo'-'dd'-'hh'.'mm'.'ss'.'ffffff                       00260002
endProcedure tod2Tst                                                    00270002
                                                                        00280002
/*--- conversion from tst to tod clock value (stck) ------------------*/00290002
tst2tod: procedure                                                      00300002
         /* we get           YYYY-Mo-DD-HH.MM.SS.FFFFFF  (db2 tst)      00310002
            but need         MO/DD/YYYY HH:MM:SS.FFFFFF */              00320002
  parse arg yyyy '-' mo '-' dd '-' hh '.' mm '.' ss '.' ffffff          00330002
  tst = mo'/'dd'/'yyyy hh':'mm':'ss'.'ffffff                            00340002
  tod = left('', 8, '?')                                                00350002
  address linkPgm "BLSUXTID tst tod"                                    00360002
  return tod                                                            00370002
endProcedure tst2Tod                                                    00380002
                                                                        00390002
/* --- convert a db2 conToken to a TOD (stck) value --------------------00400002
    Take the conttoken and split it into two 4 bytes halves.            00410002
    second half needs (Shift Left Single) by 3 bits ---> = partB        00420002
--- Shift (left half  || partB) again by 3 bits  ---------------------*/00430002
con2tod: procedure                                                      00440002
parse arg con                                                           00450002
    bi = left(x2b(c2x(con)), 64, 0)                                     00460002
    return x2c(b2x(substr(bi, 4, 29) || substr(bi, 36, 29) || '000000'))00470002
endProcedure con2Tod                                                    00480002