void db_util_datetostring(const unsigned long date, char *string) { t_datetime datetime; systime_secondstodate(date, &datetime); sprintf(string, "%4lu-%02lu-%02lu %02lu:%02lu:%02lu", datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second); }
void testdb_closecase(t_testdb *d, long test_id) { t_ptr_uint timestamp = systime_seconds(); t_datetime datetime; systime_secondstodate(timestamp, &datetime); db_query(d->d_db, NULL, "UPDATE tests SET test_finish = '%4u-%02u-%02u %02u:%02u:%02u' \ WHERE test_id = %i", datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second, test_id); }
long testdb_createcase(t_testdb *d, const char* test_name) { long test_id = 0; t_ptr_uint timestamp = systime_seconds(); t_datetime datetime; systime_secondstodate(timestamp, &datetime); db_query(d->d_db, NULL, "INSERT INTO tests ( test_name , test_start, test_finish ) \ VALUES ( \"%s\" , '%4u-%02u-%02u %02u:%02u:%02u', 0 ) ", test_name, datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second); db_query_getlastinsertid(d->d_db, &test_id); return test_id; }
void testdb_log(t_testdb *d, long test_id, const char* text, ...) { t_ptr_uint timestamp = systime_seconds(); t_datetime datetime; va_list ap; char expandedtext[2048]; va_start(ap, text); vsnprintf(expandedtext, 2048, text, ap); systime_secondstodate(timestamp, &datetime); db_query(d->d_db, NULL, "INSERT INTO logs ( test_id_ext , text , timestamp ) \ VALUES ( %i , \"%s\" , '%4u-%02u-%02u %02u:%02u:%02u' )", test_id, expandedtext, datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second); }