bool bson_append_timeval_from_s (bson_t *bson, const char *key, const char *value) { struct timeval timeval; bool ret = true; if (value && strcmp ("\\N", value) != 0) { ret = pg_timestamp_with_time_zone_from_s (value, &timeval); ret = ret && bson_append_timeval (bson, key, -1, &timeval); } return ret; }
static void test_bson_append_timeval (void) { struct timeval tv = { 0 }; bson_t *b; bson_t *b2; tv.tv_sec = 1234567890; tv.tv_usec = 0; b = bson_new(); assert(bson_append_timeval(b, "time_t", -1, &tv)); b2 = get_bson("test26.bson"); assert_bson_equal(b, b2); bson_destroy(b); bson_destroy(b2); }