From: Elena Mamontova Date: Tue, 27 Sep 2016 13:02:28 +0000 (+0300) Subject: Ticket 37. Int2TS() method changed to formatTime() function, TS2Int() X-Git-Tag: 2.409~71 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/50419f0521446b8e698a391e3c2cb3fc711733ce?hp=a096e833c2060ab274345ad6a5b7cd91abf29b9c Ticket 37. Int2TS() method changed to formatTime() function, TS2Int() method changed to readTime() function in postgresql_store_messages.cpp file. '#include "stg/common.h"' added. --- diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp index 27401e26..42a19073 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp @@ -33,6 +33,7 @@ #include +#include "stg/common.h" #include "postgresql_store.h" #include "stg/locker.h" #include "stg/message.h" @@ -89,8 +90,8 @@ query << "SELECT sp_add_message(" << "'" << elogin << "', " << "CAST(1 AS SMALLINT), " // Here need to be a version, but, it's uninitiated actually << "CAST(" << msg->header.type << " AS SMALLINT), " - << "CAST('" << Int2TS(msg->header.lastSendTime) << "' AS TIMESTAMP), " - << "CAST('" << Int2TS(msg->header.creationTime) << "' AS TIMESTAMP), " + << "CAST('" << formatTime(msg->header.lastSendTime) << "' AS TIMESTAMP), " + << "CAST('" << formatTime(msg->header.creationTime) << "' AS TIMESTAMP), " << msg->header.showTime << ", " << "CAST(" << msg->header.repeat << " AS SMALLINT), " << msg->header.repeatPeriod << ", " @@ -192,8 +193,8 @@ query << "UPDATE tb_messages SET " << "fk_user = (SELECT pk_user FROM tb_users WHERE name = '" << elogin << "'), " << "ver = " << msg.header.ver << ", " << "msg_type = " << msg.header.type << ", " - << "last_send_time = CAST('" << Int2TS(msg.header.lastSendTime) << "' AS TIMESTAMP), " - << "creation_time = CAST('" << Int2TS(msg.header.creationTime) << "' AS TIMESTAMP), " + << "last_send_time = CAST('" << formatTime(msg.header.lastSendTime) << "' AS TIMESTAMP), " + << "creation_time = CAST('" << formatTime(msg.header.creationTime) << "' AS TIMESTAMP), " << "show_time = " << msg.header.showTime << ", " << "repeat = " << msg.header.repeat << ", " << "repeat_period = " << msg.header.repeatPeriod << ", " @@ -287,8 +288,8 @@ if (tuples != 1) str2x(PQgetvalue(result, 0, 0), msg->header.ver); str2x(PQgetvalue(result, 0, 1), msg->header.type); -msg->header.lastSendTime = static_cast(TS2Int(PQgetvalue(result, 0, 2))); -msg->header.creationTime = static_cast(TS2Int(PQgetvalue(result, 0, 3))); +msg->header.lastSendTime = static_cast(readTime(PQgetvalue(result, 0, 2))); +msg->header.creationTime = static_cast(readTime(PQgetvalue(result, 0, 3))); str2x(PQgetvalue(result, 0, 4), msg->header.showTime); str2x(PQgetvalue(result, 0, 5), msg->header.repeat); str2x(PQgetvalue(result, 0, 6), msg->header.repeatPeriod); @@ -424,8 +425,8 @@ for (int i = 0; i < tuples; ++i) tuple << PQgetvalue(result, i, 0) << " "; tuple << PQgetvalue(result, i, 1) << " "; tuple << PQgetvalue(result, i, 2) << " "; - header.lastSendTime = static_cast(TS2Int(PQgetvalue(result, i, 3))); - header.creationTime = static_cast(TS2Int(PQgetvalue(result, i, 4))); + header.lastSendTime = static_cast(readTime(PQgetvalue(result, i, 3))); + header.creationTime = static_cast(readTime(PQgetvalue(result, i, 4))); tuple << PQgetvalue(result, i, 5) << " "; tuple << PQgetvalue(result, i, 6) << " "; tuple << PQgetvalue(result, i, 7) << " ";