compat / gmtime.con commit Merge branch 'hb/gitweb-project-list' (a6ca9ee)
   1#include "../git-compat-util.h"
   2#undef gmtime
   3#undef gmtime_r
   4
   5struct tm *git_gmtime(const time_t *timep)
   6{
   7        static struct tm result;
   8        return git_gmtime_r(timep, &result);
   9}
  10
  11struct tm *git_gmtime_r(const time_t *timep, struct tm *result)
  12{
  13        struct tm *ret;
  14
  15        memset(result, 0, sizeof(*result));
  16        ret = gmtime_r(timep, result);
  17
  18        /*
  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.
  22         */
  23        if (ret && !ret->tm_mday) {
  24                ret = NULL;
  25                errno = EOVERFLOW;
  26        }
  27
  28        return ret;
  29}