Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / time / gmtime.c
bloba78d554339585a7a067ec2b8a1ad1b7e1b5edf7a
1 /*
2 * gmtime.c
3 * Original Author: G. Haley
5 * Converts the calendar time pointed to by tim_p into a broken-down time
6 * expressed as Greenwich Mean Time (GMT). Returns a pointer to a structure
7 * containing the broken-down time, or a null pointer if GMT is not
8 * available.
9 */
12 FUNCTION
13 <<gmtime>>---convert time to UTC traditional form
15 INDEX
16 gmtime
17 INDEX
18 gmtime_r
20 SYNOPSIS
21 #include <time.h>
22 struct tm *gmtime(const time_t *<[clock]>);
23 struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>);
25 DESCRIPTION
26 <<gmtime>> takes the time at <[clock]> representing the number
27 of elapsed seconds since 00:00:00 on January 1, 1970, Universal
28 Coordinated Time (UTC, also known in some countries as GMT,
29 Greenwich Mean time) and converts it to a <<struct tm>>
30 representation.
32 <<gmtime>> constructs the traditional time representation in static
33 storage; each call to <<gmtime>> or <<localtime>> will overwrite the
34 information generated by previous calls to either function.
36 RETURNS
37 A pointer to the traditional time representation (<<struct tm>>).
39 PORTABILITY
40 ANSI C requires <<gmtime>>.
42 <<gmtime>> requires no supporting OS subroutines.
45 #include <stdlib.h>
46 #include <time.h>
48 #define _GMT_OFFSET 0
50 #ifdef _REENT_THREAD_LOCAL
51 _Thread_local struct __tm _tls_localtime_buf;
52 #endif
54 #ifndef _REENT_ONLY
56 struct tm *
57 gmtime (const time_t * tim_p)
59 struct _reent *reent = _REENT;
61 _REENT_CHECK_TM(reent);
62 return gmtime_r (tim_p, (struct tm *)_REENT_TM(reent));
65 #endif