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 * gmtime.c
19 * Original Author: G. Haley
20 *
21 * Converts the calendar time pointed to by tim_p into a broken-down time
22 * expressed as Greenwich Mean Time (GMT). Returns a pointer to a structure
23 * containing the broken-down time, or a null pointer if GMT is not
24 * available.
25 */
26
27 /*
28 FUNCTION
29 <<gmtime>>---convert time to UTC traditional form
30
31 INDEX
32 gmtime
33 INDEX
34 gmtime_r
35
36 SYNOPSIS
37 #include <time.h>
38 struct tm *gmtime(const time_t *<[clock]>);
39 struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>);
40
41 DESCRIPTION
42 <<gmtime>> takes the time at <[clock]> representing the number
43 of elapsed seconds since 00:00:00 on January 1, 1970, Universal
44 Coordinated Time (UTC, also known in some countries as GMT,
45 Greenwich Mean time) and converts it to a <<struct tm>>
46 representation.
47
48 <<gmtime>> constructs the traditional time representation in static
49 storage; each call to <<gmtime>> or <<localtime>> will overwrite the
50 information generated by previous calls to either function.
51
52 RETURNS
53 A pointer to the traditional time representation (<<struct tm>>).
54
55 PORTABILITY
56 ANSI C requires <<gmtime>>.
57
58 <<gmtime>> requires no supporting OS subroutines.
59 */
60
61 #include <stdlib.h>
62 #include <time.h>
63
64 #define _GMT_OFFSET 0
65
66 #ifndef _REENT_ONLY
67
68 extern NEWLIB_THREAD_LOCAL struct tm _localtime_buf;
69
70 struct tm *
gmtime(const time_t * tim_p)71 gmtime (const time_t * tim_p)
72 {
73 return gmtime_r (tim_p, &_localtime_buf);
74 }
75
76 #endif
77