123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #include "CDBHelper.h"
- #include <stdio.h>
- #include <string.h>
- namespace YADB
- {
- CDBHelper::CDBHelper()
- {
- }
- CDBHelper::~CDBHelper()
- {
- }
- void CDBHelper::String2DateTime( const char* szString, MYSQL_TIME & value )
- {
- sscanf( szString, "%d-%d-%d %d:%d:%d", &value.year, &value.month, &value.day, &value.hour, &value.minute, &value.second );
- value.second_part = 0;//microseconds
- value.neg = false;
- value.time_type = MYSQL_TIMESTAMP_DATE;
- }
- void CDBHelper::DateTime2String( const MYSQL_TIME & value, char * szString, int Length )
- {
- char szTemp[20] = { 0 };
- sprintf( szTemp, "%d-%d-%d %02d:%02d:%02d", \
- value.year, value.month, value.day, value.hour, value.minute, value.second );
- strncpy( szString, szTemp, Length );
- }
- void CDBHelper::InitMySQLTime( MYSQL_TIME & value )
- {
- value.year = 0;
- value.month = 0;
- value.day = 0;
- value.hour = 0;
- value.minute = 0;
- value.second = 0;
- value.neg = false;
- value.second_part = 0;
- value.time_type = MYSQL_TIMESTAMP_DATETIME;
- }
- }
|