timegm.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
  2. Copyright (C) 1994, 1997, 2003-2004, 2006-2007, 2009-2017 Free Software
  3. Foundation, Inc. This file is part of the GNU C Library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef _LIBC
  15. # include <config.h>
  16. #endif
  17. #include <time.h>
  18. #ifdef _LIBC
  19. typedef time_t mktime_offset_t;
  20. #else
  21. # undef __gmtime_r
  22. # define __gmtime_r gmtime_r
  23. # define __mktime_internal mktime_internal
  24. # include "mktime-internal.h"
  25. #endif
  26. time_t
  27. timegm (struct tm *tmp)
  28. {
  29. static mktime_offset_t gmtime_offset;
  30. tmp->tm_isdst = 0;
  31. return __mktime_internal (tmp, __gmtime_r, &gmtime_offset);
  32. }