/src/git/trace2/tr2_tbuf.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | #include "git-compat-util.h"  | 
2  |  | #include "tr2_tbuf.h"  | 
3  |  |  | 
4  |  | void tr2_tbuf_local_time(struct tr2_tbuf *tb)  | 
5  | 0  | { | 
6  | 0  |   struct timeval tv;  | 
7  | 0  |   struct tm tm;  | 
8  | 0  |   time_t secs;  | 
9  |  | 
  | 
10  | 0  |   gettimeofday(&tv, NULL);  | 
11  | 0  |   secs = tv.tv_sec;  | 
12  | 0  |   localtime_r(&secs, &tm);  | 
13  |  | 
  | 
14  | 0  |   xsnprintf(tb->buf, sizeof(tb->buf), "%02d:%02d:%02d.%06ld", tm.tm_hour,  | 
15  | 0  |       tm.tm_min, tm.tm_sec, (long)tv.tv_usec);  | 
16  | 0  | }  | 
17  |  |  | 
18  |  | void tr2_tbuf_utc_datetime_extended(struct tr2_tbuf *tb)  | 
19  | 0  | { | 
20  | 0  |   struct timeval tv;  | 
21  | 0  |   struct tm tm;  | 
22  | 0  |   time_t secs;  | 
23  |  | 
  | 
24  | 0  |   gettimeofday(&tv, NULL);  | 
25  | 0  |   secs = tv.tv_sec;  | 
26  | 0  |   gmtime_r(&secs, &tm);  | 
27  |  | 
  | 
28  | 0  |   xsnprintf(tb->buf, sizeof(tb->buf),  | 
29  | 0  |       "%4d-%02d-%02dT%02d:%02d:%02d.%06ldZ", tm.tm_year + 1900,  | 
30  | 0  |       tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,  | 
31  | 0  |       (long)tv.tv_usec);  | 
32  | 0  | }  | 
33  |  |  | 
34  |  | void tr2_tbuf_utc_datetime(struct tr2_tbuf *tb)  | 
35  | 0  | { | 
36  | 0  |   struct timeval tv;  | 
37  | 0  |   struct tm tm;  | 
38  | 0  |   time_t secs;  | 
39  |  | 
  | 
40  | 0  |   gettimeofday(&tv, NULL);  | 
41  | 0  |   secs = tv.tv_sec;  | 
42  | 0  |   gmtime_r(&secs, &tm);  | 
43  |  | 
  | 
44  | 0  |   xsnprintf(tb->buf, sizeof(tb->buf), "%4d%02d%02dT%02d%02d%02d.%06ldZ",  | 
45  | 0  |       tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,  | 
46  | 0  |       tm.tm_min, tm.tm_sec, (long)tv.tv_usec);  | 
47  | 0  | }  |