xref: /netbsd-src/external/bsd/file/dist/src/localtime_r.c (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
1 /*	$NetBSD: localtime_r.c,v 1.1.1.1 2017/02/10 17:42:57 christos Exp $	*/
2 
3 /*	$File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $	*/
4 
5 #include "file.h"
6 #ifndef	lint
7 #if 0
8 FILE_RCSID("@(#)$File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $")
9 #else
10 __RCSID("$NetBSD: localtime_r.c,v 1.1.1.1 2017/02/10 17:42:57 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 *
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