library/src/databases/bpdb/BP-DB.cc
// Attempt to convert a time type to a json string.
Attempt to convert a time type to a json string.
Attempt to convert a time type to a json string .
char * BP_DBMariadbConvertTimeColumnResultToJSONData(MYSQL_BIND * col_bind_info, BPDB_MARIADB_COLUMN_TYPE type)
{
	if(!col_bind_info)
		return NULL;
	if(!col_bind_info->buffer)
		return NULL;
	char *ret_buff = NULL;
	MYSQL_TIME * time_data = (MYSQL_TIME *) col_bind_info->buffer;
	char time_buff[512];
	BP_ZERO_STACK(time_buff);
	switch(type)
	{
		case BPDB_MARIADB_COLUMN_TYPE_DATE:
		case BPDB_MARIADB_COLUMN_TYPE_TIME:
		case BPDB_MARIADB_COLUMN_TYPE_DATETIME:
		case BPDB_MARIADB_COLUMN_TYPE_TIMESTAMP:
		case BPDB_MARIADB_COLUMN_TYPE_YEAR:
			sprintf
			(
					time_buff,
					"%.04u-%.02u-%.02u T%.02u:%.02u:%.02u",
					time_data->year,
					time_data->month,
					time_data->day,
					time_data->hour,
					time_data->minute,
					time_data->second
			);
			break;
		default:
			break;
	}
	if(bpstrlen(time_buff))
	{
		ret_buff = bpstrdup(time_buff);
	}
	return ret_buff;
}
char * BP_DBMariadbConvertTimeColumnResultToJSONData ( MYSQL_BIND * col_bind_info , BPDB_MARIADB_COLUMN_TYPE type ) { if ( ! col_bind_info ) return NULL ; if ( ! col_bind_info -> buffer ) return NULL ; char * ret_buff = NULL ; MYSQL_TIME * time_data = ( MYSQL_TIME * ) col_bind_info -> buffer ; char time_buff [ 512 ] ; BP_ZERO_STACK ( time_buff ) ; switch ( type ) { case BPDB_MARIADB_COLUMN_TYPE_DATE : case BPDB_MARIADB_COLUMN_TYPE_TIME : case BPDB_MARIADB_COLUMN_TYPE_DATETIME : case BPDB_MARIADB_COLUMN_TYPE_TIMESTAMP : case BPDB_MARIADB_COLUMN_TYPE_YEAR : sprintf ( time_buff , " " , time_data -> year , time_data -> month , time_data -> day , time_data -> hour , time_data -> minute , time_data -> second ) ; break ; default : break ; } if ( bpstrlen ( time_buff ) ) { ret_buff = bpstrdup ( time_buff ) ; } return ret_buff ; }
Attempt to convert a time type to a json string.
Attempt to convert a time type to a json string .
// ensure we have bind info // return buffer // set time data from buffer // time buffer // switch on type /* begin date and time data types */ // dupe the timebuf if necessary // return the filled out buffer (or null if badval)