tibDateTime
Date and time information can be stored in ActiveSpaces as date and time strings, Julian Day long or double values, or as tibDateTime values. tibDateTime consists of two 64-bit integers; one for the number of seconds since January 1, 1970 (Unix epoch), and one for the number of nanoseconds after the time that the sec component denotes.
ActiveSpaces tables can be defined, using
tibdg , with columns of type
datetime which are mapped internally to a
tibDateTime object for storing data into rows of the table. The following is the C API for setting and retrieving tibDateTime
objects into/from the rows of a table:
void tibdgRow_SetDateTime(tibEx e, tibdgRow row, const char *columnName, const tibDateTime *value) tibDateTime* tibdgRow_GetDateTime(tibEx e, tibdgRow row, const char* columnName)tibDateTime columns can be used for primary keys and for secondary indexes.
Populating tibDateTime
Windows and Unix platforms use different structures for retrieving date/time data. The following are examples of how you can get the current date and time on each platform and populate a
tibDateTime object:
- Unix platforms
-
#include <sys/types.h> #include <sys/time.h> #include “tibdg/tibdg.h” struct timeval timebuffer; (void) gettimeofday(&timebuffer, NULL); tibDateTime dt; dt.sec = timebuffer.tv_sec; dt.nsec = timebuffer.tv_usec * 1000;
- Windows
-
#include <sys/timeb.h> #include “tibdg/tibdg.h” struct __timeb64 timebuffer; _ftime64_s(&timebuffer); tibDateTime dt; dt.sec = timebuffer.time; dt.nsec = timebuffer.millitm * 1000000;
Copyright © Cloud Software Group, Inc. All rights reserved.