Blame src/gl/timegm.c

Packit aea12f
/* Convert UTC calendar time to simple time.  Like mktime but assumes UTC.
Packit aea12f
Packit Service 991b93
   Copyright (C) 1994-2020 Free Software Foundation, Inc.
Packit aea12f
   This file is part of the GNU C Library.
Packit aea12f
Packit aea12f
   The GNU C Library is free software; you can redistribute it and/or
Packit aea12f
   modify it under the terms of the GNU General Public
Packit aea12f
   License as published by the Free Software Foundation; either
Packit aea12f
   version 3 of the License, or (at your option) any later version.
Packit aea12f
Packit aea12f
   The GNU C Library is distributed in the hope that it will be useful,
Packit aea12f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit aea12f
   General Public License for more details.
Packit aea12f
Packit aea12f
   You should have received a copy of the GNU General Public
Packit aea12f
   License along with the GNU C Library; if not, see
Packit Service 991b93
   <https://www.gnu.org/licenses/>.  */
Packit aea12f
Packit aea12f
#ifndef _LIBC
Packit aea12f
# include <libc-config.h>
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#include <time.h>
Packit aea12f
#include <errno.h>
Packit aea12f
Packit aea12f
#include "mktime-internal.h"
Packit aea12f
Packit aea12f
__time64_t
Packit aea12f
__timegm64 (struct tm *tmp)
Packit aea12f
{
Packit aea12f
  static mktime_offset_t gmtime_offset;
Packit aea12f
  tmp->tm_isdst = 0;
Packit aea12f
  return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset);
Packit aea12f
}
Packit aea12f
Packit aea12f
#if defined _LIBC && __TIMESIZE != 64
Packit aea12f
Packit aea12f
libc_hidden_def (__timegm64)
Packit aea12f
Packit aea12f
time_t
Packit aea12f
timegm (struct tm *tmp)
Packit aea12f
{
Packit aea12f
  struct tm tm = *tmp;
Packit aea12f
  __time64_t t = __timegm64 (&tm;;
Packit aea12f
  if (in_time_t_range (t))
Packit aea12f
    {
Packit aea12f
      *tmp = tm;
Packit aea12f
      return t;
Packit aea12f
    }
Packit aea12f
  else
Packit aea12f
    {
Packit aea12f
      __set_errno (EOVERFLOW);
Packit aea12f
      return -1;
Packit aea12f
    }
Packit aea12f
}
Packit aea12f
Packit aea12f
#endif