Base: Move currentDateTimeString out of TimeInfo

currentDateTimeString does not have anything in common
with TimeInfo class, move it into Tools.
This commit is contained in:
Ladislav Michl
2024-01-21 17:14:47 +01:00
parent d60e7b9eae
commit 7b70d3fc6f
6 changed files with 14 additions and 12 deletions

View File

@@ -798,7 +798,7 @@ Document::Document(const char* documentName)
#ifdef FC_LOGUPDATECHAIN
Console().Log("+App::Document: %p\n", this);
#endif
std::string CreationDateString = Base::TimeInfo::currentDateTimeString();
std::string CreationDateString = Base::Tools::currentDateTimeString();
std::string Author = App::GetApplication()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document")
->GetASCII("prefAuthor", "");
@@ -1606,7 +1606,7 @@ bool Document::save ()
TipName.setValue(Tip.getValue()->getNameInDocument());
}
std::string LastModifiedDateString = Base::TimeInfo::currentDateTimeString();
std::string LastModifiedDateString = Base::Tools::currentDateTimeString();
LastModifiedDate.setValue(LastModifiedDateString.c_str());
// set author if needed
bool saveAuthor = App::GetApplication().GetParameterGroupByPath

View File

@@ -77,14 +77,6 @@ void TimeInfo::setTime_t(int64_t seconds)
timebuffer.time = seconds;
}
std::string TimeInfo::currentDateTimeString()
{
return QDateTime::currentDateTime()
.toTimeSpec(Qt::OffsetFromUTC)
.toString(Qt::ISODate)
.toStdString();
}
std::string TimeInfo::diffTime(const TimeInfo& timeStart, const TimeInfo& timeEnd)
{
std::stringstream str;

View File

@@ -81,7 +81,6 @@ public:
bool operator>=(const TimeInfo& time) const;
bool operator>(const TimeInfo& time) const;
static std::string currentDateTimeString();
static std::string diffTime(const TimeInfo& timeStart, const TimeInfo& timeEnd = TimeInfo());
static float diffTimeF(const TimeInfo& timeStart, const TimeInfo& timeEnd = TimeInfo());
bool isNull() const;

View File

@@ -26,6 +26,7 @@
#include <sstream>
#include <locale>
#include <iostream>
#include <QDateTime>
#include <QElapsedTimer>
#endif
@@ -365,6 +366,14 @@ std::string Base::Tools::joinList(const std::vector<std::string>& vec, const std
return str.str();
}
std::string Base::Tools::currentDateTimeString()
{
return QDateTime::currentDateTime()
.toTimeSpec(Qt::OffsetFromUTC)
.toString(Qt::ISODate)
.toStdString();
}
// ----------------------------------------------------------------------------
using namespace Base;

View File

@@ -346,6 +346,8 @@ struct BaseExport Tools
* @return
*/
static std::string joinList(const std::vector<std::string>& vec, const std::string& sep = ", ");
static std::string currentDateTimeString();
};

View File

@@ -1359,7 +1359,7 @@ bool Cloud::Module::cloudSave(const char* BucketName)
doc->TipName.setValue(doc->Tip.getValue()->getNameInDocument());
}
std::string LastModifiedDateString = Base::TimeInfo::currentDateTimeString();
std::string LastModifiedDateString = Base::Tools::currentDateTimeString();
doc->LastModifiedDate.setValue(LastModifiedDateString.c_str());
// set author if needed
bool saveAuthor = App::GetApplication()