On 12 June 2015 at 10:39, Janet Graff <
[email protected]> wrote:

> STCK-STCK          difference in times since the start of the started task
> + 1972/01/01     add in base STCK time to get a STCK value again
> STCKCONV           convert that to DATE=YYYYMMDD TIME=DEC
> ED                       make it character based
>
> sequence so I have
>
> 1972/01/03 23:15:06.238744
>
> What I'd like is
>
> 2 days 23:15:06.238744
>
> I can calculate the date difference by hand (in C based off of the
> character representation of the date) of course.  Unless someone knows of a
> nifty method to get the elapsed number of days from the data that I have?
>

I wouldn't start with the formatted data. Once you have the difference in
seconds (or microseconds or the like) in binary (STCK-STCK), then you can
sequentially divide by the size of each unit to the left, adding the
remainder to the right of your output as you go. You may want to skip the
microseconds to seconds part, because you can already do that with code you
have. But you can do it all the same way to be consistent. When it really
comes into play is when you have a mixed-base notation like weeks, days,
hours, minutes, seconds. So let's say you have the elapsed time in seconds.
Divide that by the number of seconds in a minute (60, duh), and make the
remainder the right-hand part of your output. Divide the integer quotient
by the number of minutes in an hour (60), display the remainder as Minutes,
divide the integer quotient by the number of hours in a day (24), and so on
up to weeks. Or stop wherever you want - perhaps at days. So you can
display any number of days this way, even crossing week, month, and year
boundaries without ambiguity.

The newer Divide Single instructions (probably DSGF) are easy to use for
this. You can have a loop with a little table of the numbers, or maybe it's
too small and just as easy to read without a loop.

Just composing on the fly here - probably various errors...

STCK  start
...
STCK  end
LG    G1,end
SLG   G1,start   Now G1 contains the 64-bit TOD-unit elapsed time
SRLG  G1,12      Convert to microseconds in G1
DSGF  G0,=F'1000000' Whole seconds in G1 and remainder in G0
* format G0 to the right of the decimal point
DSGF  G0,=F'60'  Whole minutes in G1, and remaining seconds in G0
* format G0 to the left of the decimal point
DSGF  G0,=F'60'  Whole hours in G1, and remaining minutes in G0
* format G0 as minutes
DSGF  G0,=F'24'  Whole days in G1, and remaining hours in G0
* format G0 as hours
* format G1 as whole days or continue to weeks if you want

Life gets tricky when you hit months, because of course these are not all
the same number of the next lower unit (weeks). And worse, they are not
simply algorithmically related. But it's a pretty unlikely display format:

Your job ran for 3 Months, 2 Weeks, 5 Days, 27 Minutes, and 34.123456
seconds.

Surely better to stop at days:

Your job ran for 110 Days 18 Minutes, and 34.123456 seconds.

More realistically
Your job ran for 110 days and 19 minutes.
or
Your job ran for 110 days.

Tony H.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to