Add Hour, Minute, Second to logging system.

This commit is contained in:
realaltffour 2020-04-15 15:27:53 +03:00
parent aa4d661f66
commit 40d5b2acbb
No known key found for this signature in database
GPG Key ID: 7115CD2AC9A76A56
2 changed files with 18 additions and 9 deletions

View File

@ -17,9 +17,12 @@ using nlohmann::json;
/////////////// DATA CONTAINING STRUCTURES ///////////////////
struct Date {
int day = 0;
int month = 0; // 0-11
int year = 0; // + 1900 for currentyear
int day = 0;
int month = 0; // 0-11
int year = 0; // + 1900 for currentyear
int hour = 0;
int minute = 0;
int second = 0;
};
struct Project {

View File

@ -21,9 +21,12 @@ void logEntry(const std::string& msg, EntryType type) {
time_t t = time(0);
struct tm* currentTime = localtime(&t);
ev.creationDate.day = currentTime->tm_mday;
ev.creationDate.month = currentTime->tm_mon;
ev.creationDate.year = currentTime->tm_year + 1900;
ev.creationDate.day = currentTime->tm_mday;
ev.creationDate.month = currentTime->tm_mon;
ev.creationDate.year = currentTime->tm_year + 1900;
ev.creationDate.hour = currentTime->tm_hour;
ev.creationDate.minute = currentTime->tm_min;
ev.creationDate.second = currentTime->tm_sec;
if (!s_log.entries)
s_log.entries = new std::list<Entry>();
@ -38,10 +41,13 @@ void writeLog(const std::string& loc, bool append) {
f.open(LOC_LOG);
for (auto entry: *s_log.entries) {
// TODO: ADD HOUR, MINUTE, SECONDS
f << "[ " << entry.creationDate.day << "/" << entry.creationDate.month
<< "/" << entry.creationDate.year << " ] "
<< "[ " << std::to_string(entry.timerTime) << " ] "
<< t2str(entry.type) << " - " << entry.mesg << "\n";
<< "/" << entry.creationDate.year << " ] [ "
<< entry.creationDate.hour << ":" << entry.creationDate.minute << ":"
<< entry.creationDate.second << " ] [ "
<< std::to_string(entry.timerTime) << " ] " << t2str(entry.type)
<< " - " << entry.mesg << "\n";
}
f.close();
}