gmtime.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Convert `time_t' to `struct tm' in UTC.
  2. Copyright (C) 1991-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library 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 GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <time.h>
  16. /* Return the `struct tm' representation of *T in UTC,
  17. using *TP to store the result. */
  18. struct tm *
  19. __gmtime64_r (const __time64_t *t, struct tm *tp)
  20. {
  21. return __tz_convert (*t, 0, tp);
  22. }
  23. /* Provide a 32-bit variant if needed. */
  24. #if __TIMESIZE != 64
  25. libc_hidden_def (__gmtime64_r)
  26. struct tm *
  27. __gmtime_r (const time_t *t, struct tm *tp)
  28. {
  29. __time64_t t64 = *t;
  30. return __gmtime64_r (&t64, tp);
  31. }
  32. #endif
  33. libc_hidden_def (__gmtime_r)
  34. weak_alias (__gmtime_r, gmtime_r)
  35. /* Return the `struct tm' representation of *T in UTC. */
  36. struct tm *
  37. __gmtime64 (const __time64_t *t)
  38. {
  39. return __tz_convert (*t, 0, &_tmbuf);
  40. }
  41. /* Provide a 32-bit variant if needed. */
  42. #if __TIMESIZE != 64
  43. libc_hidden_def (__gmtime64)
  44. struct tm *
  45. gmtime (const time_t *t)
  46. {
  47. __time64_t t64 = *t;
  48. return __gmtime64 (&t64);
  49. }
  50. #endif