Blame src/gl/time_r.c

Packit Service 4684c1
/* Reentrant time functions like localtime_r.
Packit Service 4684c1
Packit Service 4684c1
   Copyright (C) 2003, 2006-2007, 2010-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software; you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 3, or (at your option)
Packit Service 4684c1
   any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program 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
Packit Service 4684c1
   GNU General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU General Public License along
Packit Service 4684c1
   with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
/* Written by Paul Eggert.  */
Packit Service 4684c1
Packit Service 4684c1
#include <config.h>
Packit Service 4684c1
Packit Service 4684c1
#include <time.h>
Packit Service 4684c1
Packit Service 4684c1
static struct tm *
Packit Service 4684c1
copy_tm_result (struct tm *dest, struct tm const *src)
Packit Service 4684c1
{
Packit Service 4684c1
  if (! src)
Packit Service 4684c1
    return 0;
Packit Service 4684c1
  *dest = *src;
Packit Service 4684c1
  return dest;
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
struct tm *
Packit Service 4684c1
gmtime_r (time_t const * restrict t, struct tm * restrict tp)
Packit Service 4684c1
{
Packit Service 4684c1
  return copy_tm_result (tp, gmtime (t));
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
struct tm *
Packit Service 4684c1
localtime_r (time_t const * restrict t, struct tm * restrict tp)
Packit Service 4684c1
{
Packit Service 4684c1
  return copy_tm_result (tp, localtime (t));
Packit Service 4684c1
}