Unix Epoch

Question: The Unix epoch is the starting point of time for Unix based computing systems, and it is set to January 1, 1970. Unix epoch time an an integer which represents the time elapsed since the Unix epoch. In q, we can cast integers to timestamps, with the integer being interpreted as the number of nanoseconds since epoch. The epoch for q, however, is January 1, 2000, so this poses a problem if you simply cast a Unix epoch time to a q timestamp. The Unix epoch has to be accounted for and adjusted. Define a function 'frmUnixEp' (from Unix epoch) that takes in an integer representing the Unix epoch time (in nanoseconds) and converts it to q epoch time.

More Information:



                                q)frmUnixEp 1589841242176*1e6 //convert to nanos
q)"p"$frmUnixEp 1589841242176*1e6
q)"p"$frmUnixEp 1e9*"J"$first system"date +%s" // convert current Unix epoch time to q timestamp


functions math temporal
Searchable Tags
algorithms api architecture asynchronous c csv data structures dictionaries disk feedhandler finance functions ingestion ipc iterators machine learning math multithreading optimizations realtime shared library sql statistics streaming strings tables temporal utility websockets