Sherbel Nasra
Sherbel Nasra

Reputation: 21

How to convert epoch unix time to TOD clock (STCK)?

Please can you help me to convert epoch Unix time to TOD clock (STCK) 8 bytes. e.g :

  1. EPOCH time in Hex = '175BC71AFE2'X
  2. EPOCH time in Decimal = 1,605,184,368,610
  3. and I want to convert this decimal to STCK (TOD clock time)?

Upvotes: 1

Views: 1290

Answers (1)

Hogstrom
Hogstrom

Reputation: 3761

The Store Clock Instruction STCK takes the TOD clock and stores it in an 8-byte field. Bit position 31 is incremented approximately every 1.048576 seconds. Here is a link that provides a way to convert a STCK to a current date.

See this answer to a similar question of converting a current time to a TOD value for comparing timestamps in a LogStream using Rexx here

I'm not sure what your application is but also be aware that there is a STCKE instruction that uses an extended format.

Quoted here for convenience

This works for me in a Rexx procedure:

Tod = (epoc*4096000000)+9048018124800000000

TOD (Time-of-Day in S360, S370, S390 & z/Arch IBM's archs) is a 
64bit counter whose Bit position 31 is incremented every 1.048576 
seconds, starting at 1900-01-01.

So, 2**32/1.048576 = 4096000000 = 1 sec.

9048... is the difference between 1900-01-01 and epoch 1970-01-01 in TOD units.

Refer to the Principles of Operation for more information on page 7-182 regarding STCK and STCKE formats.

Upvotes: 1

Related Questions