X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/bd66b226090397493de8d87649b2bbad3ac89e36..b2b89723a2427bba8290bd6967a1ab39cbb630be:/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp index 22feadf0..582c5445 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp @@ -26,13 +26,15 @@ * */ -#include - #include "firebird_store.h" + #include "stg/ibpp.h" +#include "stg/common.h" + +#include //----------------------------------------------------------------------------- -time_t ts2time_t(const IBPP::Timestamp & ts) const +time_t ts2time_t(const IBPP::Timestamp & ts) { char buf[32]; int year, month, day, hour, min, sec; @@ -41,13 +43,15 @@ time_t ts2time_t(const IBPP::Timestamp & ts) const memset(&time_tm, 0, sizeof(time_tm)); ts.GetDate(year, month, day); ts.GetTime(hour, min, sec); + if (year < 1990) + return 0; sprintf(buf, "%d-%d-%d %d:%d:%d", year, month, day, hour, min, sec); stg_strptime(buf, "%Y-%m-%d %H:%M:%S", &time_tm); return mktime(&time_tm); } //----------------------------------------------------------------------------- -void time_t2ts(time_t t, IBPP::Timestamp * ts) const +void time_t2ts(time_t t, IBPP::Timestamp * ts) { struct tm res; @@ -56,7 +60,7 @@ void time_t2ts(time_t t, IBPP::Timestamp * ts) const *ts = IBPP::Timestamp(res.tm_year + 1900, res.tm_mon + 1, res.tm_mday, res.tm_hour, res.tm_min, res.tm_sec); } //----------------------------------------------------------------------------- -void ym2date(int year, int month, IBPP::Date * date) const +void ym2date(int year, int month, IBPP::Date * date) { date->SetDate(year + 1900, month + 1, 1); date->EndOfMonth();