OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [time/] [gmtime.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/*
2
 * gmtime.c
3
 * Original Author:     G. Haley
4
 *
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
 */
10
 
11
/*
12
FUNCTION
13
<<gmtime>>---convert time to UTC traditional form
14
 
15
INDEX
16
        gmtime
17
 
18
ANSI_SYNOPSIS
19
        #include <time.h>
20
        struct tm *gmtime(const time_t *<[clock]>);
21
        struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>);
22
 
23
TRAD_SYNOPSIS
24
        #include <time.h>
25
        struct tm *gmtime(<[clock]>)
26
        const time_t *<[clock]>;
27
        struct tm *gmtime_r(<[clock]>, <[res]>)
28
        const time_t *<[clock]>;
29
        struct tm *<[res]>;
30
 
31
DESCRIPTION
32
<<gmtime>> assumes the time at <[clock]> represents a local time.
33
<<gmtime>> converts it to UTC (Universal Coordinated Time, also known in some
34
countries as GMT, Greenwich Mean time), then converts the
35
representation from the arithmetic representation to
36
the traditional representation defined by <<struct tm>>.
37
 
38
<<gmtime>> constructs the traditional time representation in static
39
storage; each call to <<gmtime>> or <<localtime>> will overwrite the
40
information generated by previous calls to either function.
41
 
42
RETURNS
43
A pointer to the traditional time representation (<<struct tm>>).
44
 
45
PORTABILITY
46
ANSI C requires <<gmtime>>.
47
 
48
<<gmtime>> requires no supporting OS subroutines.
49
*/
50
 
51
#include <stdlib.h>
52
#include <time.h>
53
 
54
#define _GMT_OFFSET 0
55
 
56
#ifndef _REENT_ONLY
57
 
58
struct tm *
59
_DEFUN (gmtime, (tim_p),
60
        _CONST time_t * tim_p)
61
{
62
  time_t tim = *tim_p + _GMT_OFFSET;
63
 
64
  return (localtime (&tim));
65
}
66
 
67
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.