diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 5f98db67c..04b625add 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -593,11 +593,11 @@ Document::Document(void) #ifdef FC_LOGUPDATECHAIN Console().Log("+App::Document: %p\n",this); #endif - + std::string CreationDateString = Base::TimeInfo::currentDateTimeString(); ADD_PROPERTY_TYPE(Label,("Unnamed"),0,Prop_None,"The name of the document"); ADD_PROPERTY_TYPE(FileName,(""),0,Prop_ReadOnly,"The path to the file where the document is saved to"); ADD_PROPERTY_TYPE(CreatedBy,(""),0,Prop_None,"The creator of the document"); - ADD_PROPERTY_TYPE(CreationDate,(Base::TimeInfo::currentDateTimeString()),0,Prop_ReadOnly,"Date of creation"); + ADD_PROPERTY_TYPE(CreationDate,(CreationDateString.c_str()),0,Prop_ReadOnly,"Date of creation"); ADD_PROPERTY_TYPE(LastModifiedBy,(""),0,Prop_None,0); ADD_PROPERTY_TYPE(LastModifiedDate,("Unknown"),0,Prop_ReadOnly,"Date of last modification"); ADD_PROPERTY_TYPE(Company,(""),0,Prop_None,"Additional tag to save the the name of the company"); @@ -948,7 +948,8 @@ bool Document::save (void) compression = Base::clamp(compression, Z_NO_COMPRESSION, Z_BEST_COMPRESSION); if (*(FileName.getValue()) != '\0') { - LastModifiedDate.setValue(Base::TimeInfo::currentDateTimeString()); + std::string LastModifiedDateString = Base::TimeInfo::currentDateTimeString(); + LastModifiedDate.setValue(LastModifiedDateString.c_str()); // make a tmp. file where to save the project data first and then rename to // the actual file name. This may be useful if overwriting an existing file // fails so that the data of the work up to now isn't lost. diff --git a/src/Base/TimeInfo.cpp b/src/Base/TimeInfo.cpp index 2e2470148..a35259da1 100644 --- a/src/Base/TimeInfo.cpp +++ b/src/Base/TimeInfo.cpp @@ -68,16 +68,16 @@ void TimeInfo::setTime_t (uint64_t seconds) timebuffer.time = seconds; } -const char* TimeInfo::currentDateTimeString() +std::string TimeInfo::currentDateTimeString() { + char timebuff[30]= {0}; struct tm* systime; time_t sec; time(&sec); systime = localtime(&sec); - - const char* dt = asctime(systime); - return dt; + strftime(timebuff,30,"%Y-%m-%dT%H:%M:%S%z",systime); + return std::string(timebuff); } std::string TimeInfo::diffTime(const TimeInfo &timeStart,const TimeInfo &timeEnd ) diff --git a/src/Base/TimeInfo.h b/src/Base/TimeInfo.h index d2ad6c202..7d73c5661 100644 --- a/src/Base/TimeInfo.h +++ b/src/Base/TimeInfo.h @@ -63,7 +63,7 @@ public: bool operator >= (const TimeInfo &time) const; bool operator > (const TimeInfo &time) const; - static const char* currentDateTimeString(); + 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;