1 /*
2 Copyright (c) 1994 Cygnus Support.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms are permitted
6 provided that the above copyright notice and this paragraph are
7 duplicated in all such forms and that any documentation,
8 and/or other materials related to such
9 distribution and use acknowledge that the software was developed
10 at Cygnus Support, Inc.  Cygnus Support, Inc. may not be used to
11 endorse or promote products derived from this software without
12 specific prior written permission.
13 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  */
17 /*
18  * localtime.c
19  */
20 
21 /*
22 FUNCTION
23 <<localtime>>---convert time to local representation
24 
25 INDEX
26 	localtime
27 INDEX
28 	localtime_r
29 
30 SYNOPSIS
31 	#include <time.h>
32 	struct tm *localtime(time_t *<[clock]>);
33 	struct tm *localtime_r(time_t *<[clock]>, struct tm *<[res]>);
34 
35 DESCRIPTION
36 <<localtime>> converts the time at <[clock]> into local time, then
37 converts its representation from the arithmetic representation to the
38 traditional representation defined by <<struct tm>>.
39 
40 <<localtime>> constructs the traditional time representation in static
41 storage; each call to <<gmtime>> or <<localtime>> will overwrite the
42 information generated by previous calls to either function.
43 
44 <<mktime>> is the inverse of <<localtime>>.
45 
46 RETURNS
47 A pointer to the traditional time representation (<<struct tm>>).
48 
49 PORTABILITY
50 ANSI C requires <<localtime>>.
51 
52 <<localtime>> requires no supporting OS subroutines.
53 */
54 
55 #include <stdlib.h>
56 #include <time.h>
57 
58 #ifndef _REENT_ONLY
59 
60 extern NEWLIB_THREAD_LOCAL struct tm _localtime_buf;
61 
62 struct tm *
localtime(const time_t * tim_p)63 localtime (const time_t * tim_p)
64 {
65   return localtime_r (tim_p, &_localtime_buf);
66 }
67 
68 #endif
69