diff --git a/core/item.cpp b/core/item.cpp index b7aabe9..1ac0b9b 100755 --- a/core/item.cpp +++ b/core/item.cpp @@ -20,7 +20,7 @@ Item::Item() // !! IMPROVE ME -// now we have Request::start_time and Request::start_tm +// now we have Request::start_time and Request::start_date // we can somehow get the current time from the request // may setting the date should be completetly removed from here? void Item::SetDateToNow() diff --git a/core/log.cpp b/core/log.cpp index 50da18d..e0b6548 100755 --- a/core/log.cpp +++ b/core/log.cpp @@ -227,16 +227,6 @@ return *this; } -Log & Log::operator<<(const tm & tm_) -{ - if( current_level <= log_level ) - { - buffer << tm_; - } - -return *this; -} - Log & Log::operator<<(const PT::Date & date) { @@ -249,6 +239,7 @@ return *this; } + Log & Log::operator<<(LogManipulators m) { switch(m) diff --git a/core/log.h b/core/log.h index 8ce17a4..9e17e91 100755 --- a/core/log.h +++ b/core/log.h @@ -44,7 +44,6 @@ public: Log & operator<<(double s); Log & operator<<(const PT::Space & space); Log & operator<<(LogManipulators m); - Log & operator<<(const tm & tm_); Log & operator<<(const PT::Date & date); diff --git a/core/textstream.h b/core/textstream.h index 074c2e0..226af6d 100755 --- a/core/textstream.h +++ b/core/textstream.h @@ -60,7 +60,6 @@ public: TextStream & operator<<(double); TextStream & operator<<(const void *);// printing a pointer TextStream & operator<<(const PT::Space & space); - TextStream & operator<<(const tm & tm_); TextStream & operator<<(const PT::Date & date); TextStream & Write(const char * buf, size_t len); @@ -318,26 +317,6 @@ return *this; } -template -TextStream & TextStream::operator<<(const tm & tm_) -{ -char buf[50]; - - sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d", - tm_.tm_year + 1900, - tm_.tm_mon + 1, - tm_.tm_mday, - tm_.tm_hour, - tm_.tm_min, - tm_.tm_sec); - - for(size_t i=0 ; buf[i] ; ++i) - buffer += buf[i]; - -return *this; -} - - template TextStream & TextStream::operator<<(const PT::Date & date) diff --git a/db/dbbase.cpp b/db/dbbase.cpp index f5a542c..9806018 100755 --- a/db/dbbase.cpp +++ b/db/dbbase.cpp @@ -156,7 +156,7 @@ return res; const std::wstring & DbBase::AssertValueWide(PGresult * r, int row, int col) { const char * res = AssertValue(r, row, col); - static std::wstring temp_wide_value; // !! dac jako skladowa klasy (niestatyczna) + static std::wstring temp_wide_value; // !! IMPROVE ME add as a class field (nonstatic) PT::UTF8ToWide(res, temp_wide_value); @@ -217,11 +217,6 @@ unsigned int DbBase::AssertValueUInt(PGresult * r, int row, int col) } -tm DbBase::AssertValueTm(PGresult * r, int row, int col) -{ - return ConvertTime(AssertValue(r, row, col)); -} - PT::Date DbBase::AssertValueDate(PGresult * r, int row, int col) { @@ -338,55 +333,8 @@ return AssertValueLong(r, 0, 0); -tm DbBase::ConvertTime(const char * str) -{ -tm t; - - memset(&t, 0, sizeof(t)); - - if( !str ) - return t; - - size_t len = strlen(str); - - if( len != 19 ) - { - // the format must be like this: 2008-12-31 22:30:00 - log << log1 << "DbBase: ConvertTime: unknown time format: \"" << str << "\"" << logend; - return t; - } - - t.tm_year = Toi(str + 0) - 1900; /* year - 1900 */ - t.tm_mon = Toi(str + 5) - 1; /* month of year (0 - 11) */ - t.tm_mday = Toi(str + 8); /* day of month (1 - 31) */ - t.tm_hour = Toi(str + 11); /* hours (0 - 23) */ - t.tm_min = Toi(str + 14); /* minutes (0 - 59) */ - t.tm_sec = Toi(str + 17); /* seconds (0 - 60) */ - - // t.tm_wday = 0; /* day of week (Sunday = 0) */ - // t.tm_yday = 0; /* day of year (0 - 365) */ - // t.tm_isdst = 0; /* is summer time in effect? */ - // t.tm_zone = 0; // const_cast(""); /* abbreviation of timezone name */ - -return t; -} -const char * DbBase::ConvertTime(const tm & t) -{ -// not thread safe -static char buffer[100]; - - sprintf(buffer, "%04d-%02d-%02d %02d:%02d:%02d", - t.tm_year + 1900, - t.tm_mon + 1, - t.tm_mday, - t.tm_hour, - t.tm_min, - t.tm_sec); - -return buffer; -} diff --git a/db/dbbase.h b/db/dbbase.h index 22446eb..fc83aab 100755 --- a/db/dbbase.h +++ b/db/dbbase.h @@ -50,7 +50,6 @@ public: static bool AssertValueBool(PGresult * r, int row, int col); static unsigned long AssertValueULong(PGresult * r, int row, int col); static unsigned int AssertValueUInt(PGresult * r, int row, int col); - static tm AssertValueTm(PGresult * r, int row, int col); static PT::Date AssertValueDate(PGresult * r, int row, int col); // non static assignments @@ -64,8 +63,6 @@ public: int Cols(PGresult * r); long AffectedRows(PGresult * r); - static tm ConvertTime(const char * str); - static const char * ConvertTime(const tm & t); // warning: it uses its own static buffer void CreateIdList(const std::vector & id_tab, std::wstring & list, bool add_parentheses = true); Error DoCommand(const DbTextStream & command); diff --git a/db/dbitemcolumns.cpp b/db/dbitemcolumns.cpp index 2fd725b..dda1e81 100755 --- a/db/dbitemcolumns.cpp +++ b/db/dbitemcolumns.cpp @@ -55,8 +55,8 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item) if( user_id != -1 ) item.user_id = DbBase::AssertValueLong(r, row, user_id); if( group_id != -1 ) item.group_id = DbBase::AssertValueLong(r, row, group_id); if( privileges != -1 ) item.privileges = DbBase::AssertValueInt(r, row, privileges); - if( date_creation != -1 ) item.date_creation = DbBase::AssertValueTm(r, row, date_creation); - if( date_modification != -1 ) item.date_modification = DbBase::AssertValueTm(r, row, date_modification); + if( date_creation != -1 ) item.date_creation = DbBase::AssertValueDate(r, row, date_creation); + if( date_modification != -1 ) item.date_modification = DbBase::AssertValueDate(r, row, date_modification); if( type != -1 ) item.type = static_cast( DbBase::AssertValueInt(r, row, type) ); if( parent_id != -1 ) item.parent_id = DbBase::AssertValueLong(r, row, parent_id); if( content_id != -1 ) item.content_id = DbBase::AssertValueLong(r, row, content_id); diff --git a/db/dbtextstream.cpp b/db/dbtextstream.cpp index a5cc88f..a1bc8ef 100755 --- a/db/dbtextstream.cpp +++ b/db/dbtextstream.cpp @@ -194,18 +194,15 @@ return *this; } -DbTextStream & DbTextStream::operator<<(RawText t) -{ - buffer += ConvertTime(t.par); - was_param = false; - -return *this; -} DbTextStream & DbTextStream::operator<<(RawText date) { - date.par.Serialize(*this); + tmp_stream.Clear(); + date.par.Serialize(tmp_stream); + AssignString(tmp_stream.CStr(), buffer, false); + tmp_stream.Clear(); + was_param = false; return *this; @@ -529,18 +526,6 @@ return *this; -DbTextStream & DbTextStream::operator<<(const tm & t) -{ - if( was_param ) - buffer += ", "; - - buffer += '\''; - buffer += ConvertTime(t); - buffer += '\''; - was_param = true; - -return *this; -} DbTextStream & DbTextStream::operator<<(const std::vector & tabid) @@ -566,22 +551,6 @@ return *this; } -const char * DbTextStream::ConvertTime(const tm & t) -{ -// not thread safe -static char buffer[100]; - - sprintf(buffer, "%04d-%02d-%02d %02d:%02d:%02d", - t.tm_year + 1900, - t.tm_mon + 1, - t.tm_mday, - t.tm_hour, - t.tm_min, - t.tm_sec); - -return buffer; -} - diff --git a/db/dbtextstream.h b/db/dbtextstream.h index c519196..297ce5a 100755 --- a/db/dbtextstream.h +++ b/db/dbtextstream.h @@ -113,7 +113,6 @@ public: DbTextStream & operator<<(RawText raw); DbTextStream & operator<<(RawText raw); DbTextStream & operator<<(RawText raw); - DbTextStream & operator<<(RawText t); DbTextStream & operator<<(RawText date); @@ -151,14 +150,11 @@ public: DbTextStream & operator<<(unsigned long); DbTextStream & operator<<(double); DbTextStream & operator<<(const void *); - DbTextStream & operator<<(const tm & t); DbTextStream & operator<<(const std::vector & tabid); DbTextStream & operator<<(const PT::Space & space); DbTextStream & operator<<(const PT::Date & date); - static const char * ConvertTime(const tm & t); - private: bool was_param; diff --git a/plugins/thread/Makefile.dep b/plugins/thread/Makefile.dep index a3455be..48a929c 100755 --- a/plugins/thread/Makefile.dep +++ b/plugins/thread/Makefile.dep @@ -90,13 +90,12 @@ funthread.o: ../../core/run.h ../../core/users.h ../../core/groups.h funthread.o: ../../core/group.h ../../core/loadavg.h ../../core/image.h funthread.o: ../../core/threadmanager.h ../../core/synchro.h tdb.h thread.h funthread.o: ../../db/dbbase.h threadinfo.h -init.o: tdb.h thread.h ../../db/dbbase.h ../../core/error.h reply.h -init.o: ../../functions/functionbase.h ../../core/item.h -init.o: ../../../pikotools/space/space.h ../../../pikotools/date/date.h -init.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h -init.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/misc.h -init.o: ../../core/item.h ../../core/requesttypes.h -init.o: ../../../pikotools/space/spaceparser.h +init.o: tdb.h thread.h ../../../pikotools/date/date.h ../../db/dbbase.h +init.o: ../../core/error.h reply.h ../../functions/functionbase.h +init.o: ../../core/item.h ../../../pikotools/space/space.h ../../db/db.h +init.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h +init.o: ../../core/textstream.h ../../core/misc.h ../../core/item.h +init.o: ../../core/requesttypes.h ../../../pikotools/space/spaceparser.h init.o: ../../../pikotools/space/space.h ../../db/dbitemquery.h init.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h init.o: ../../core/dircontainer.h ../../core/ugcontainer.h ../../core/log.h @@ -238,7 +237,8 @@ showthreads.o: ../../core/groups.h ../../core/group.h ../../core/loadavg.h showthreads.o: ../../core/image.h ../../core/threadmanager.h showthreads.o: ../../core/synchro.h tdb.h thread.h ../../db/dbbase.h showthreads.o: threadinfo.h -tdb.o: tdb.h thread.h ../../db/dbbase.h ../../core/error.h ../../core/log.h +tdb.o: tdb.h thread.h ../../../pikotools/date/date.h ../../db/dbbase.h +tdb.o: ../../core/error.h ../../core/log.h templates.o: threadinfo.h ../../core/item.h ../../../pikotools/space/space.h templates.o: ../../../pikotools/date/date.h ../../core/system.h templates.o: ../../core/job.h ../../core/basethread.h ../../core/synchro.h diff --git a/plugins/thread/tdb.cpp b/plugins/thread/tdb.cpp index 0414142..7b3003d 100755 --- a/plugins/thread/tdb.cpp +++ b/plugins/thread/tdb.cpp @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2010, Tomasz Sowa + * Copyright (c) 2010-2012, Tomasz Sowa * All rights reserved. * */ @@ -50,7 +50,7 @@ void TDb::SetThread(PGresult * r, int col, Thread & thread) thread.replies = AssertValueLong(r, col, creplies); thread.closed = AssertValueBool(r, col, cclosed); thread.last_item_id = AssertValueLong(r, col, clast_item); - thread.last_item_date_modification = AssertValueTm(r, col, cdate_modification); + thread.last_item_date_modification = AssertValueDate(r, col, cdate_modification); thread.last_item_user_id = AssertValueLong(r, col, cuser_id); AssertValueWide(r, col, cguest, thread.last_item_guest_name); } diff --git a/plugins/thread/thread.h b/plugins/thread/thread.h index 49ee9fd..b132944 100755 --- a/plugins/thread/thread.h +++ b/plugins/thread/thread.h @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2009-2010, Tomasz Sowa + * Copyright (c) 2009-2012, Tomasz Sowa * All rights reserved. * */ @@ -12,14 +12,13 @@ #include #include +#include "date/date.h" namespace Thread { - - class Thread { public: @@ -30,7 +29,7 @@ public: // the last file in a thread long last_item_id; - tm last_item_date_modification; + PT::Date last_item_date_modification; long last_item_user_id; std::wstring last_item_guest_name; @@ -43,7 +42,7 @@ public: replies = 0; last_item_id = -1; last_item_user_id = -1; - memset(&last_item_date_modification, 0, sizeof(tm)); + last_item_date_modification.Clear(); last_item_guest_name.clear(); } diff --git a/templates/htmltextstream.cpp b/templates/htmltextstream.cpp index 83389c2..7458ce4 100755 --- a/templates/htmltextstream.cpp +++ b/templates/htmltextstream.cpp @@ -12,9 +12,6 @@ - - - /* without escaping */ @@ -401,15 +398,6 @@ return *this; -HtmlTextStream & HtmlTextStream::operator<<(const tm & t) -{ - buffer += DateToStr(t); // from core/misc - -return *this; -} - - - HtmlTextStream & HtmlTextStream::operator<<(const PT::Space & space) { tmp_stream.Clear(); diff --git a/templates/htmltextstream.h b/templates/htmltextstream.h index 873ca4d..50ebf78 100755 --- a/templates/htmltextstream.h +++ b/templates/htmltextstream.h @@ -143,7 +143,6 @@ public: HtmlTextStream & operator<<(unsigned long); HtmlTextStream & operator<<(double); HtmlTextStream & operator<<(const void *); - HtmlTextStream & operator<<(const tm & t); HtmlTextStream & operator<<(const PT::Space & space); HtmlTextStream & operator<<(const PT::Date & Date);