https://github.com/git/git
Raw File
Tip revision: c8dd1e3bb1152844983558802a52c9e4c17652b4 authored by Junio C Hamano on 05 May 2017, 04:03:40 UTC
Git 2.7.5
Tip revision: c8dd1e3
gmtime.c
#include "../git-compat-util.h"
#undef gmtime
#undef gmtime_r

struct tm *git_gmtime(const time_t *timep)
{
	static struct tm result;
	return git_gmtime_r(timep, &result);
}

struct tm *git_gmtime_r(const time_t *timep, struct tm *result)
{
	struct tm *ret;

	memset(result, 0, sizeof(*result));
	ret = gmtime_r(timep, result);

	/*
	 * Rather than NULL, FreeBSD gmtime simply leaves the "struct tm"
	 * untouched when it encounters overflow. Since "mday" cannot otherwise
	 * be zero, we can test this very quickly.
	 */
	if (ret && !ret->tm_mday) {
		ret = NULL;
		errno = EOVERFLOW;
	}

	return ret;
}
back to top