Blame src/gl/timegm.c

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