MCPcopy Index your code
hub / github.com/git/git / show_date

Function show_date

date.c:288–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288const char *show_date(timestamp_t time, int tz, struct date_mode mode)
289{
290 struct tm *tm;
291 struct tm tmbuf = { 0 };
292 struct tm human_tm = { 0 };
293 int human_tz = -1;
294 static struct strbuf timebuf = STRBUF_INIT;
295
296 if (mode.type == DATE_UNIX) {
297 strbuf_reset(&timebuf);
298 strbuf_addf(&timebuf, "%"PRItime, time);
299 return timebuf.buf;
300 }
301
302 if (mode.type == DATE_HUMAN) {
303 struct timeval now;
304
305 get_time(&now);
306
307 /* Fill in the data for "current time" in human_tz and human_tm */
308 human_tz = local_time_tzoffset(now.tv_sec, &human_tm);
309 }
310
311 if (mode.local)
312 tz = local_tzoffset(time);
313
314 if (mode.type == DATE_RAW) {
315 strbuf_reset(&timebuf);
316 strbuf_addf(&timebuf, "%"PRItime" %+05d", time, tz);
317 return timebuf.buf;
318 }
319
320 if (mode.type == DATE_RELATIVE) {
321 strbuf_reset(&timebuf);
322 show_date_relative(time, &timebuf);
323 return timebuf.buf;
324 }
325
326 if (mode.local)
327 tm = time_to_tm_local(time, &tmbuf);
328 else
329 tm = time_to_tm(time, tz, &tmbuf);
330 if (!tm) {
331 tm = time_to_tm(0, 0, &tmbuf);
332 tz = 0;
333 }
334
335 strbuf_reset(&timebuf);
336 if (mode.type == DATE_SHORT)
337 strbuf_addf(&timebuf, "%04d-%02d-%02d", tm->tm_year + 1900,
338 tm->tm_mon + 1, tm->tm_mday);
339 else if (mode.type == DATE_ISO8601)
340 strbuf_addf(&timebuf, "%04d-%02d-%02d %02d:%02d:%02d %+05d",
341 tm->tm_year + 1900,
342 tm->tm_mon + 1,
343 tm->tm_mday,
344 tm->tm_hour, tm->tm_min, tm->tm_sec,
345 tz);

Callers 15

grab_dateFunction · 0.85
show_ident_dateFunction · 0.85
show_ambiguous_objectFunction · 0.85
get_oid_basicFunction · 0.85
read_ref_at_entFunction · 0.85
migrate_one_reflog_entryFunction · 0.85
get_reflog_selectorFunction · 0.85
hdr_dateFunction · 0.85
verify_ssh_signed_bufferFunction · 0.85
show_human_datesFunction · 0.85
show_datesFunction · 0.85
parse_datesFunction · 0.85

Calls 10

strbuf_addfFunction · 0.85
get_timeFunction · 0.85
local_time_tzoffsetFunction · 0.85
local_tzoffsetFunction · 0.85
show_date_relativeFunction · 0.85
time_to_tm_localFunction · 0.85
time_to_tmFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_addftimeFunction · 0.85
show_date_normalFunction · 0.85

Tested by 4

show_human_datesFunction · 0.68
show_datesFunction · 0.68
parse_datesFunction · 0.68
parse_approxidateFunction · 0.68