MCPcopy Create free account
hub / github.com/git/git / update_tm

Function update_tm

date.c:1080–1101  ·  view source on GitHub ↗

* Relative time update (eg "2 days ago"). If we haven't set the time * yet, we need to set it from current time. * * The tm->tm_mday field has an additional logic of using negative values * for date adjustments: -2 means yesterday and -3 the day before that, * and so on. The idea is to defer such adjustments until we are sure * there's no explicit mday specification in the approxidate stri

Source from the content-addressed store, hash-verified

1078 * there's no explicit mday specification in the approxidate string.
1079 */
1080static time_t update_tm(struct tm *tm, struct tm *now, time_t sec)
1081{
1082 time_t n;
1083
1084 if (tm->tm_mday < 0) {
1085 int offset = tm->tm_mday + 1;
1086 if (sec == 0 && offset < 0)
1087 sec = -offset * 24*60*60;
1088 tm->tm_mday = now->tm_mday;
1089 }
1090 if (tm->tm_mon < 0)
1091 tm->tm_mon = now->tm_mon;
1092 if (tm->tm_year < 0) {
1093 tm->tm_year = now->tm_year;
1094 if (tm->tm_mon > now->tm_mon)
1095 tm->tm_year--;
1096 }
1097
1098 n = mktime(tm) - sec;
1099 localtime_r(&n, tm);
1100 return n;
1101}
1102
1103/*
1104 * Do we have a pending number at the end, or when

Callers 5

date_nowFunction · 0.85
date_yesterdayFunction · 0.85
date_todayFunction · 0.85
approxidate_alphaFunction · 0.85
approxidate_strFunction · 0.85

Calls 1

localtime_rFunction · 0.85

Tested by

no test coverage detected