Okay, in response to absolutely no popular requests, here is how to convert
a TOD to a UNIX time:

Add CVTLSO. There's your all-important leap seconds, affine or otherwise.

Divide by (4096 * 10^6). A common assembler approach is to shift right 12
and then divide by one million. That gives you seconds since the start of
the S/360 era (1/1/1900). I will leave as an exercise for the reader how to
get whole seconds and fractional seconds (tenths, milliseconds, etc.).
Alternatively or additionally, you might want to round up.

Subtract 2208988800. That turns out to be exactly the number of seconds from
the start of the S/360 era (1900) to the start of the UNIX era (1970). I
suppose if you were desperate to save a couple of cycles in the case of
repetitive conversions you could adjust that constant for CVTLSO and only do
one subtract.

If the result is negative you are out of luck. The C library routines do not
support negative times (times before 1/1/1970).

Charles


-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]]
On Behalf Of Paul Gilmartin
Sent: Friday, November 17, 2017 7:14 AM
To: [email protected]
Subject: Re: A modest proposal: LE enabled HLASM + C runtime

On 2017-11-17, at 08:01:13, Charles Mills wrote:

> Another library routine to take a look at is strftime(). There are often
questions here about how to format a date or time a particular way. You will
also need some source of time in UNIX format (seconds since 1970) ...
>  
That might be an affine transformation of STCK-CVTLSO.

> ... such as time() and then either gmtime() or localtime().

-- gil

Reply via email to