changed to readTime() function in postgresql_store_users.cpp file.
'#include "stg/common.h"' added.
#include "stg/const.h"
#include "stg/locker.h"
#include "../../../stg_timer.h"
#include "stg/const.h"
#include "stg/locker.h"
#include "../../../stg_timer.h"
query << "UPDATE tb_users SET "
"cash = " << stat.cash << ", "
"free_mb = " << stat.freeMb << ", "
query << "UPDATE tb_users SET "
"cash = " << stat.cash << ", "
"free_mb = " << stat.freeMb << ", "
- "last_activity_time = CAST('" << Int2TS(stat.lastActivityTime) << "' AS TIMESTAMP), "
+ "last_activity_time = CAST('" << formatTime(stat.lastActivityTime) << "' AS TIMESTAMP), "
"last_cash_add = " << stat.lastCashAdd << ", "
"last_cash_add = " << stat.lastCashAdd << ", "
- "last_cash_add_time = CAST('" << Int2TS(stat.lastCashAddTime) << "' AS TIMESTAMP), "
+ "last_cash_add_time = CAST('" << formatTime(stat.lastCashAddTime) << "' AS TIMESTAMP), "
"passive_time = " << stat.passiveTime << " "
"WHERE name = '" << elogin << "'";
"passive_time = " << stat.passiveTime << " "
"WHERE name = '" << elogin << "'";
"address = '" << eaddress << "', "
"always_online = " << (conf.alwaysOnline ? "'t'" : "'f'") << ", "
"credit = " << conf.credit << ", "
"address = '" << eaddress << "', "
"always_online = " << (conf.alwaysOnline ? "'t'" : "'f'") << ", "
"credit = " << conf.credit << ", "
- "credit_expire = CAST('" << Int2TS(conf.creditExpire) << "' AS TIMESTAMP), "
+ "credit_expire = CAST('" << formatTime(conf.creditExpire) << "' AS TIMESTAMP), "
"disabled = " << (conf.disabled ? "'t'" : "'f'") << ", "
"disabled_detail_stat = " << (conf.disabledDetailStat ? "'t'" : "'f'") << ", "
"email = '" << eemail << "', "
"disabled = " << (conf.disabled ? "'t'" : "'f'") << ", "
"disabled_detail_stat = " << (conf.disabledDetailStat ? "'t'" : "'f'") << ", "
"email = '" << eemail << "', "
std::stringstream tuple;
tuple << PQgetvalue(result, 0, 0) << " ";
tuple << PQgetvalue(result, 0, 1) << " ";
std::stringstream tuple;
tuple << PQgetvalue(result, 0, 0) << " ";
tuple << PQgetvalue(result, 0, 1) << " ";
- stat->lastActivityTime = TS2Int(PQgetvalue(result, 0, 2));
+ stat->lastActivityTime = readTime(PQgetvalue(result, 0, 2));
tuple << PQgetvalue(result, 0, 3) << " ";
tuple << PQgetvalue(result, 0, 3) << " ";
- stat->lastCashAddTime = TS2Int(PQgetvalue(result, 0, 4));
+ stat->lastCashAddTime = readTime(PQgetvalue(result, 0, 4));
tuple << PQgetvalue(result, 0, 5) << " ";
PQclear(result);
tuple << PQgetvalue(result, 0, 5) << " ";
PQclear(result);
query << "SELECT dir_num, upload, download "
"FROM tb_stats_traffic "
"WHERE fk_user IN (SELECT pk_user FROM tb_users WHERE name = '" << elogin << "') AND "
query << "SELECT dir_num, upload, download "
"FROM tb_stats_traffic "
"WHERE fk_user IN (SELECT pk_user FROM tb_users WHERE name = '" << elogin << "') AND "
- "DATE_TRUNC('month', stats_date) = DATE_TRUNC('month', CAST('" << Int2TS(stgTime) << "' AS TIMESTAMP))";
+ "DATE_TRUNC('month', stats_date) = DATE_TRUNC('month', CAST('" << formatTime(stgTime) << "' AS TIMESTAMP))";
result = PQexec(connection, query.str().c_str());
}
result = PQexec(connection, query.str().c_str());
}
conf->address = PQgetvalue(result, 0, 1); // address
conf->alwaysOnline = !strncmp(PQgetvalue(result, 0, 2), "t", 1);
tuple << PQgetvalue(result, 0, 3) << " "; // credit
conf->address = PQgetvalue(result, 0, 1); // address
conf->alwaysOnline = !strncmp(PQgetvalue(result, 0, 2), "t", 1);
tuple << PQgetvalue(result, 0, 3) << " "; // credit
- conf->creditExpire = TS2Int(PQgetvalue(result, 0, 4)); // creditExpire
+ conf->creditExpire = readTime(PQgetvalue(result, 0, 4)); // creditExpire
conf->disabled = !strncmp(PQgetvalue(result, 0, 5), "t", 1);
conf->disabledDetailStat = !strncmp(PQgetvalue(result, 0, 6), "t", 1);
conf->email = PQgetvalue(result, 0, 7); // email
conf->disabled = !strncmp(PQgetvalue(result, 0, 5), "t", 1);
conf->disabledDetailStat = !strncmp(PQgetvalue(result, 0, 6), "t", 1);
conf->email = PQgetvalue(result, 0, 7); // email
"'" << eadminLogin << "', CAST('"
<< inet_ntostring(admIP) << "/32' AS INET), "
"'" << eparam << "', "
"'" << eadminLogin << "', CAST('"
<< inet_ntostring(admIP) << "/32' AS INET), "
"'" << eparam << "', "
- "CAST('" << Int2TS(stgTime) << "' AS TIMESTAMP), "
+ "CAST('" << formatTime(stgTime) << "' AS TIMESTAMP), "
"'" << eold << "', "
"'" << enew << "', "
"'" << emessage << "')";
"'" << eold << "', "
"'" << enew << "', "
"'" << emessage << "')";
{
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
{
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
- "CAST('" << Int2TS(stgTime) << "' AS TIMESTAMP), "
+ "CAST('" << formatTime(stgTime) << "' AS TIMESTAMP), "
"'c', CAST('"
<< inet_ntostring(ip) << "/32' AS INET), 0)";
}
"'c', CAST('"
<< inet_ntostring(ip) << "/32' AS INET), 0)";
}
{
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
{
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
- "CAST('" << Int2TS(stgTime) << "' AS TIMESTAMP), "
+ "CAST('" << formatTime(stgTime) << "' AS TIMESTAMP), "
"'c', CAST('"
<< inet_ntostring(ip) << "/32' AS INET), 0, 0, '')";
}
"'c', CAST('"
<< inet_ntostring(ip) << "/32' AS INET), 0, 0, '')";
}
// Old database version - no freeMb logging support
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
// Old database version - no freeMb logging support
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
- "CAST('" << Int2TS(stgTime) << "' AS TIMESTAMP), "
+ "CAST('" << formatTime(stgTime) << "' AS TIMESTAMP), "
"'d', CAST('0.0.0.0/0' AS INET), "
<< cash << ")";
}
"'d', CAST('0.0.0.0/0' AS INET), "
<< cash << ")";
}
{
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
{
query << "SELECT sp_add_session_log_entry("
"'" << elogin << "', "
- "CAST('" << Int2TS(stgTime) << "' AS TIMESTAMP), "
+ "CAST('" << formatTime(stgTime) << "' AS TIMESTAMP), "
"'d', CAST('0.0.0.0/0' AS INET), "
<< cash << ", " << freeMb << ", '" << ereason << "')";
}
"'d', CAST('0.0.0.0/0' AS INET), "
<< cash << ", " << freeMb << ", '" << ereason << "')";
}
"(till_time, from_time, fk_user, "
"dir_num, ip, download, upload, cost) "
"VALUES ("
"(till_time, from_time, fk_user, "
"dir_num, ip, download, upload, cost) "
"VALUES ("
- "CAST('" << Int2TS(currTime) << "' AS TIMESTAMP), "
- "CAST('" << Int2TS(lastStat) << "' AS TIMESTAMP), "
+ "CAST('" << formatTime(currTime) << "' AS TIMESTAMP), "
+ "CAST('" << formatTime(lastStat) << "' AS TIMESTAMP), "
"(SELECT pk_user FROM tb_users WHERE name = '" << elogin << "'), "
<< it->first.dir << ", "
<< "CAST('" << inet_ntostring(it->first.ip) << "' AS INET), "
"(SELECT pk_user FROM tb_users WHERE name = '" << elogin << "'), "
<< it->first.dir << ", "
<< "CAST('" << inet_ntostring(it->first.ip) << "' AS INET), "