2022-02-17 15:26:49 +00:00
|
|
|
## Contains types and utilities for timestamps.
|
|
|
|
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
|
|
|
|
import sqlite3_abi
|
|
|
|
|
|
|
|
type Timestamp* = int64
|
|
|
|
|
|
|
|
const TIMESTAMP_TABLE_TYPE* = "INTEGER"
|
|
|
|
|
|
|
|
proc getNanosecondTime*[T](timeInSeconds: T): Timestamp =
|
2022-03-18 10:36:27 +00:00
|
|
|
var ns = Timestamp(timeInSeconds.int64 * 1000_000_000.int64)
|
2022-02-17 15:26:49 +00:00
|
|
|
return ns
|
|
|
|
|
|
|
|
proc getMicrosecondTime*[T](timeInSeconds: T): Timestamp =
|
2022-03-18 10:36:27 +00:00
|
|
|
var us = Timestamp(timeInSeconds.int64 * 1000_000.int64)
|
2022-02-17 15:26:49 +00:00
|
|
|
return us
|
|
|
|
|
|
|
|
proc getMillisecondTime*[T](timeInSeconds: T): Timestamp =
|
2022-03-18 10:36:27 +00:00
|
|
|
var ms = Timestamp(timeInSeconds.int64 * 1000.int64)
|
2022-02-17 15:26:49 +00:00
|
|
|
return ms
|
|
|
|
|
|
|
|
proc column_timestamp*(a1: ptr sqlite3_stmt, iCol: cint): int64 =
|
|
|
|
return sqlite3_column_int64(a1, iCol)
|