Thanks you so much. -----Original Message----- From: IBM Mainframe Assembler List [mailto:[email protected]] On Behalf Of Tony Harminc Sent: Monday, April 10, 2017 11:09 AM To: [email protected] Subject: Re: CONVTOD Help
On 10 April 2017 at 11:38, Ward, Mike S <[email protected]> wrote: > Hello, list friends. I was wondering if one of you could give me a > little help with a time problem that I have not been able to solve. I have the need to provide the number of seconds since 1970 for a project that I'm working on. I have been using a combination of the STCK and the CONVTOD to try and get the results, but I'm just not that good at math or time functions. If someone could steer me in the right direction I would really appreciate it. Hi Mike, If you want to have truly accurate results, including all the leap seconds baggage (Hi Gil), you will need to dig a bit deeper. If you don't mind being potentially off by a second or three, here is some code I wrote about 20 years ago that works, and shows what you need to do. The result is left in R14. STCK DWORD S/370 clock in IBM TOD units (bit 51 = 1 uS) LM R14,R15,DWORD TOD CLOCK UNITS in R14,R15 SRDL R14,12 MICROSECONDS SINCE JAN 1, 1900 SL R15,=FL8'2208902400000000'+4 - RIGHT HALF of conversion factor BC 11,*+6 BRANCH ON NO BORROW BCTR R14,R0 -1 FOR BORROW SL R14,=FL8'2208902400000000' - LEFT HALF of conversion factor D R14,=F'1000000' SECONDS SINCE JAN 1, 1970 ... DWORD DS D This was written before zArch and its 64-bit registers, so it does a 64-bit calculation using 32-bit registers. Still works fine, of course, but could be shortened. That magic number 2208902400000000 is the conversion factor, in microsoeconds, between 1900 and 1970. Of course the value in DWORD doesn't have to come directly from STCK. It can as well be a stored value, but take care that it's not before 1970... Tony H. ========================== This email, and any files transmitted with it, is confidential and intended solely for the use of the individual or entity to which it is addressed. If you have received this email in error, please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this message by mistake and delete this e-mail from your system. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
