Skip to main content

ktj

Function ktj 

Source
pub unsafe extern "C" fn ktj(qtype: I, nanoseconds: J) -> K
Expand description

Constructor of q timestamp from elapsed time in nanoseconds since kdb+ epoch (2000.01.01) or timespan object from nanoseconds.

use kdbplus::qtype;
use kdbplus::api::*;
use kdbplus::api::native::*;

#[no_mangle]
pub extern "C" fn create_timestamp(_: K) -> K{
  // 2015.03.16D00:00:00:00.000000000
  unsafe{ktj(qtype::TIMESTAMP_ATOM as I, 479779200000000000)}
}

#[no_mangle]
pub extern "C" fn create_timespan(_: K) -> K{
  // -1D01:30:00.001234567
  unsafe{ktj(qtype::TIMESPAN_ATOM as I, -91800001234567)}
}
q)hanko: libc_api_examples 2: (`create_timestamp; 1);
q)hanko[]
2015.03.16D00:00:00.000000000
q)duration: libc_api_examples 2: (`create_timespan; 1);
q)duration[]
-1D01:30:00.001234567