Skip to content

Commit 72708ec

Browse files
committed
Added mS to time.
1 parent 9871ba8 commit 72708ec

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: src/eotd.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <assert.h>
3535
#include <ctype.h>
3636
#include <string.h>
37-
#include <time.h>
37+
#include <sys/time.h>
3838

3939
#include "textcolor.h"
4040
#include "eotd_defs.h"
@@ -359,13 +359,14 @@ void eotd_to_text (unsigned char *eotd, int eotd_len, char *text, int text_size)
359359
}
360360

361361
#ifdef EOTD_TIMESTAMP
362-
time_t t = time(NULL);
363-
struct tm *now = localtime(&t);
362+
struct timeval tv;
363+
gettimeofday(&tv, NULL);
364+
struct tm *now = localtime(&tv.tv_sec);
364365
char date_buffer[32];
365366
strlcat(text, "ts=", text_size);
366-
sprintf(date_buffer, "%d-%02d-%02dT%02d:%02d:%02d,",
367+
sprintf(date_buffer, "%d-%02d-%02dT%02d:%02d:%02d.%03d,",
367368
now->tm_year + 1900, now->tm_mon + 1, now->tm_mday,
368-
now->tm_hour, now->tm_min, now->tm_sec);
369+
now->tm_hour, now->tm_min, now->tm_sec, tv.tv_usec / 1000);
369370
strlcat(text, date_buffer, text_size);
370371
#endif
371372

0 commit comments

Comments
 (0)