Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/trace2/tr2_tbuf.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / trace2 / tr2_tbuf.c` 47 lines ยท 1061 bytes Raw Blame History 1 #include "git-compat-util.h" 2 #include "tr2_tbuf.h" 3 4 void tr2_tbuf_local_time(struct tr2_tbuf *tb) 5 { 6 struct timeval tv; 7 struct tm tm; 8 time_t secs; 9 10 gettimeofday(&tv, NULL); 11 secs = tv.tv_sec; 12 localtime_r(&secs, &tm); 13 14 xsnprintf(tb->buf, sizeof(tb->buf), "%02d:%02d:%02d.%06ld", tm.tm_hour, 15 tm.tm_min, tm.tm_sec, (long)tv.tv_usec); 16 } 17 18 void tr2_tbuf_utc_datetime_extended(struct tr2_tbuf *tb) 19 { 20 struct timeval tv; 21 struct tm tm; 22 time_t secs; 23 24 gettimeofday(&tv, NULL); 25 secs = tv.tv_sec; 26 gmtime_r(&secs, &tm); 27 28 xsnprintf(tb->buf, sizeof(tb->buf), 29 "%4d-%02d-%02dT%02d:%02d:%02d.%06ldZ", tm.tm_year + 1900, 30 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, 31 (long)tv.tv_usec); 32 } 33 34 void tr2_tbuf_utc_datetime(struct tr2_tbuf *tb) 35 { 36 struct timeval tv; 37 struct tm tm; 38 time_t secs; 39 40 gettimeofday(&tv, NULL); 41 secs = tv.tv_sec; 42 gmtime_r(&secs, &tm); 43 44 xsnprintf(tb->buf, sizeof(tb->buf), "%4d%02d%02dT%02d%02d%02d.%06ldZ", 45 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, 46 tm.tm_min, tm.tm_sec, (long)tv.tv_usec); 47 }