use ISO 8601 timestamps including timezone

for creation and last changed properties
This commit is contained in:
Sebastian Hoogen 2014-12-09 17:53:59 +01:00
parent fc14611c93
commit 7a8492fddc
3 changed files with 9 additions and 8 deletions

View File

@ -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<int>(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.

View File

@ -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 )

View File

@ -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;