xref: /netbsd-src/external/bsd/file/dist/src/localtime_r.c (revision e15daa8be9575f7ad2ca804c7c7c2d7f8e182d98)
1 /*	$NetBSD: localtime_r.c,v 1.1.1.2 2023/08/18 18:36:49 christos Exp $	*/
2 
3 /*	$File: localtime_r.c,v 1.4 2022/09/24 20:30:13 christos Exp $	*/
4 
5 #include "file.h"
6 #ifndef	lint
7 #if 0
8 FILE_RCSID("@(#)$File: localtime_r.c,v 1.4 2022/09/24 20:30:13 christos Exp $")
9 #else
10 __RCSID("$NetBSD: localtime_r.c,v 1.1.1.2 2023/08/18 18:36:49 christos Exp $");
11 #endif
12 #endif	/* lint */
13 #include <time.h>
14 #include <string.h>
15 
16 /* asctime_r is not thread-safe anyway */
17 struct tm *
localtime_r(const time_t * t,struct tm * tm)18 localtime_r(const time_t *t, struct tm *tm)
19 {
20 	struct tm *tmp = localtime(t);
21 	if (tmp == NULL)
22 		return NULL;
23 	memcpy(tm, tmp, sizeof(*tm));
24 	return tmp;
25 }
26