localtime_r.c 448 B

12345678910111213141516171819
  1. /* $File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $ */
  2. #include "file.h"
  3. #ifndef lint
  4. FILE_RCSID("@(#)$File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $")
  5. #endif /* lint */
  6. #include <time.h>
  7. #include <string.h>
  8. /* asctime_r is not thread-safe anyway */
  9. struct tm *
  10. localtime_r(const time_t *t, struct tm *tm)
  11. {
  12. struct tm *tmp = localtime(t);
  13. if (tmp == NULL)
  14. return NULL;
  15. memcpy(tm, tmp, sizeof(*tm));
  16. return tmp;
  17. }