1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-20 13:16:36 +02:00

easier way to format timestamps

This commit is contained in:
Jfreegman
2014-03-12 03:08:13 -04:00
parent 5e377639c8
commit ce76896eb3
2 changed files with 9 additions and 10 deletions

View File

@ -51,10 +51,9 @@ void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log)
sprintf(&ident[2], "%02X", key[2] & 0xff);
ident[KEY_IDENT_DIGITS*2+1] = '\0';
} else {
struct tm *tminfo = get_time();
snprintf(ident, sizeof(ident),
"%04d-%02d-%02d[%d:%02d:%02d]", tminfo->tm_year+1900,tminfo->tm_mon+1, tminfo->tm_mday,
tminfo->tm_hour, tminfo->tm_min, tminfo->tm_sec);
uint8_t s[MAX_STR_SIZE];
strftime(s, MAX_STR_SIZE, "%Y-%m-%d[%H:%M:%S]", get_time());
snprintf(ident, sizeof(ident), "%s", s);
path_len += strlen(ident) + 1;
}
@ -96,10 +95,9 @@ void write_to_log(uint8_t *msg, uint8_t *name, struct chatlog *log, bool event)
else
snprintf(name_frmt, sizeof(name_frmt), "%s:", name);
struct tm *tminfo = get_time();
fprintf(log->file,"%04d/%02d/%02d [%d:%02d:%02d] %s %s\n", tminfo->tm_year+1900,
tminfo->tm_mon+1, tminfo->tm_mday, tminfo->tm_hour, tminfo->tm_min,
tminfo->tm_sec, name_frmt, msg);
uint8_t s[MAX_STR_SIZE];
strftime(s, MAX_STR_SIZE, "%Y/%m/%d [%H:%M:%S]", get_time());
fprintf(log->file,"%s %s %s\n", s, name_frmt, msg);
uint64_t curtime = (uint64_t) time(NULL);