Merge branch 'js/blame-lib'
[git/raj.git] / compat / gmtime.c
blobe8362dd2b965ee4d1724bc58d2645983a2293181
1 #include "../git-compat-util.h"
2 #undef gmtime
3 #undef gmtime_r
5 struct tm *git_gmtime(const time_t *timep)
7 static struct tm result;
8 return git_gmtime_r(timep, &result);
11 struct tm *git_gmtime_r(const time_t *timep, struct tm *result)
13 struct tm *ret;
15 memset(result, 0, sizeof(*result));
16 ret = gmtime_r(timep, result);
19 * Rather than NULL, FreeBSD gmtime simply leaves the "struct tm"
20 * untouched when it encounters overflow. Since "mday" cannot otherwise
21 * be zero, we can test this very quickly.
23 if (ret && !ret->tm_mday) {
24 ret = NULL;
25 errno = EOVERFLOW;
28 return ret;