Does anyone have a Rexx routine to format the STCK timestamp(8 bytes) as
dd/mm/yyyy hh:mm:ss.nnnn and the difference of two STCKs as number of days
and hh.mm.ss.nnnn.
I have searched the archive with no luck.
Thanks in advance.
Al
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX
You're welcome to the code below.
Mark L. Wheeler
IT Infrastructure, 3M Center B224-4N-20, St Paul MN 55144
Tel: (651) 733-4355, Fax: (651) 736-7689
mlwheeler at mmm.com
--
"I have this theory that if one person can go out of their way to show
compassion then it will start a chain reaction of the same. People will
never know how far a little kindness can go." Rachel Joy Scott
/* TOD2CLCK EXEC
REXX function to convert TOD to external clock time.
Format: TOD2CLCK(tod,datefmt,offset)
Where:
tod is a value from the TOD clock
See IBM System 370 XA Principles of Operation for
explanation of format.
datefmt is the format of the output date field.
Default: 'S'.
See HELP REXX DATE for permissible values.
offset is offset (in hours) from GMT (ex. CDT = -5.0).
Default: 0.
Author: Mark Wheeler, 3M Company
Date: 8 Sep 2003
*/
arg tod, datefmt, offset
if datefmt = '' then
datefmt = 'S'
if offset = '' then
microseconds_offset = 0
else
microseconds_offset = offset * 3600000000 /* Microseconds per hour */
numeric digits 16
tod_l = length(tod)
select
when datatype(tod,'X'),
& tod_l = 16 then
tod_b = x2b(tod)
when datatype(tod,'B'),
& tod_l >= 52,
& tod_l <= 64 then
tod_b = tod
when tod_l = 8 then
tod_b = c2b(tod)
otherwise
return /* Invalid value of "tod" */
end
tod_d = b2d(left(tod_b,52)) + microseconds_offset
days_since_19000101 = tod_d % 86400000000 /* Microsecs per day */
days_since_00000101 = days_since_19000101 + 693595
date = date(datefmt,days_since_00000101,'B')
microsecs_since_midnight = tod_d // 86400000000
secs_since_midnight = microsecs_since_midnight / 1000000
hh = right( secs_since_midnight % 3600 ,2,0)
mm = right( secs_since_midnight % 60 // 60 ,2,0)
ss = right(format(secs_since_midnight // 60 ,,6),9,0)
time = hh':'mm':'ss
return date time
al chu
<al_chu123@OPTUSN
ET.COM.AU> To
Sent by: TSO REXX TSO-...@VM.MARIST.EDU
Discussion List cc
<TSO-...@VM.MARI
ST.EDU> Subject
Format STCK time stamp
02/03/2008 09:43
PM
Please respond to
TSO REXX
Discussion List
<TSO-...@VM.MARI
ST.EDU>
Thanks very much for your help.
Function B2D() doesn't work in my machine. I had to change it to x2d(b2x()).
It's working fine.
Thanks again.
Al
> Hi Mark
>
> Thanks very much for your help.
> Function B2D() doesn't work in my machine. I had to change it to
x2d(b2x()).
> It's working fine.
> Thanks again.
> Al
Sorry Al. Here's something I have from 1987. I think I'm the author (looks
like my coding style), and the timing is right because it was right after I
came to work at 3M. Can't say for sure twenty years later....
Mark Wheeler
/*
B2D
+--------------------------------------------------------------------+
| |
| B2D(binary-string(,n) |
| |
+--------------------------------------------------------------------+
Binary to Decimal. Converts binary-string (a string of binary
digits) to decimal. If the result cannot be expressed as a whole
number, an error results. That is, the result must have no more than
NUMERIC DIGITS digits.
binary-string may be the null string.
If n is not specified, binary-string is taken to be an unsigned number.
Here are some examples:
B2D('00001110') + 14
B2D('10000001') + 129
B2D('111110000001') + 3969
B2D('1111111110000001') + 65409
B2D('f1f1f0f0f0f0f0f0'x) + 240
If n is specified, binary-string is taken to represent a two's
complement number expressed as n binary digits, and is converted
to a REXX whole number that may, therefore, be negative. If n is 0,
0 is always returned.
If necessary, binary-string is padded on the left with 0 digits
(note, not "sign-extended"), or truncated on the left, to length
n digits; (that is, as though RIGHT(string,n,'0') had been executed).
Here are some examples:
B2D('10000001',8) + -127
B2D('10000001',16) + 129
B2D('1111000010000001',16) + -3967
B2D('1111000010000001',12) + 129
B2D('1111000010000001',8) + -127
B2D('1111000010000001',4) + 1
B2D('0000000000110001',0) + 0
Implementation maximum: The input string may not have more than 2000
binary digits that will be significant in forming the final result.
Leading sign characters (0 and 1) do not count towards this total.
*/
if arg() < 1 | arg() > 2 then /* Only one or two arguments valid */
return /* Incorrect call to routine */
arg bin, binlen
numeric digits 603 /* Number of decimal digits in 16**500 */
signal on syntax
if binlen = '' then
return x2d(b2x(bin))
else
do
hexlen = (binlen+3)%4 /* One hex char per four binary digits */
if binlen > length(bin) then /* Input string long enough? */
bin = right(bin,binlen,0) /* extend with leading zeroes */
else
do
bin = right(bin,binlen) /* else truncate it, get the sign, */
sign = left(bin,1) /* and propagate it out to a full */
bin = right(bin,hexlen*4,sign) /* hex char because we are */
end /* setting up for X2D, remember! */
return x2d(b2x(bin),hexlen)
end
syntax:
return /* Incorrect call to routine */