Post Reply 
Unix/Linux Epoch Time Converter..
12-31-2017, 07:21 PM (This post was last modified: 12-31-2017 07:27 PM by Bill Duncan.)
Post: #10
RE: Unix/Linux Epoch Time Converter..
I thought I'd try my hand in doing an HP-48GX RPL version. Haven't used RPL for awhile, so excuse me if it isn't optimal..

The nice things about the RPL version is that it can test the depth of the stack (so use the current date/time if you haven't entered anything) and, of course it can display the entire date/time string on a single line..

->EPOCH
Code:

<<
  DEPTH IF 2 < THEN
    DATE TIME
  END
  -> D T
  <<
    1.01197 D DDAYS
    86400 *
    T HMS->
    3600 * + 18000 + IP
  >>
>>

and..
EPOCH->
Code:

<<
  18000 - DUP
  86400 / IP 1.01197 SWAP DATE+
  SWAP 86400 MOD
  3600 / ->HMS
  DUP2 TSTR CLLCD
  7 DISP 7 FREEZE
>>

The last routine leaves the date and time in the stack as well as displaying the string.

As in the original version, 18000 is for EST (Eastern Standard Time) and is the number of seconds relative to GMT or UTC. I've put several instructions on a single line for clarity. You should be able to test one against the other by executing "->EPOCH" then translating back with "EPOCH->".

Hope these routines are useful to other unix/linux sysadmins.. Wink
Cheers.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Unix/Linux Epoch Time Converter.. - Bill Duncan - 12-31-2017 07:21 PM



User(s) browsing this thread: 1 Guest(s)